pssh_box 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a6bb262bbf2468e221e28e6039db1b1dbff43dd90768bf27ccd4d380740d4bd
4
- data.tar.gz: 5dfd15b64af6e743eaa9432174cb690b3a80a204410c7727728263e8414e13ca
3
+ metadata.gz: a9b3e35812098db35aae931bb2b14e879625b56ceb7001323f504002eb7d538d
4
+ data.tar.gz: b708d02ed8554be4d665344b03b943f9ee992cba14354c05f9f4b6d01de36163
5
5
  SHA512:
6
- metadata.gz: 42bd2ccacb5b4016c26337a7cbce3d2f9019628af63ec23a98b6e5d0caba1e6a553f368679ed71874d59b41214f2af45f211e0bb9296ffd341238c338c1e39ed
7
- data.tar.gz: bc14228b095f93a9e0fb187ab9806e7b2959ea649ca4f29baccb58b199b6d9c35983706b4dfa853ca4bc5ed40355b5b5949953dcc23345b789a44dc604319904
6
+ metadata.gz: 886e0327377e89873769ccf15b6d8b7dded4b8e636576b426f8193ea12ff2b1197c6fb469d28931707686d743cc8ca37e271f9da677a28a62d0f75fdf2059785
7
+ data.tar.gz: 364f98a00418e93fcb02c4505490684309ffce452264fbb5ccf898ec0376d6c249dcf17be28ecded9e9566dc73c7248a038a3bf3b6c189fbf4e7305488864939
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pssh_box (0.0.1)
4
+ pssh_box (0.1.0)
5
5
  ruby-uuid (~> 0.0.1)
6
6
 
7
7
  GEM
@@ -25,21 +25,39 @@ module PsshBox
25
25
 
26
26
  def self.build_pssh_bytes(key_ids, pssh_data, pssh_version, system_id)
27
27
  pssh_bytes = 'pssh'.bytes
28
- pssh_bytes += int_to_four_bytes(pssh_version << 24).bytes
29
- pssh_bytes += uuid_to_bytes(system_id).bytes
28
+ pssh_bytes += version_bytes(pssh_version)
29
+ pssh_bytes += system_id_bytes(system_id)
30
30
  if pssh_version == 1
31
- pssh_bytes += int_to_four_bytes(key_ids.length).bytes
32
- key_ids.each do |key_id|
33
- pssh_bytes += uuid_to_bytes(key_id).bytes
34
- end
31
+ pssh_bytes += key_id_bytes(key_ids)
35
32
  end
36
- pssh_bytes += int_to_four_bytes(pssh_data.length).bytes
37
- pssh_bytes += pssh_data
33
+ pssh_bytes += pssh_data_bytes(pssh_data)
38
34
 
39
- length_including_prefix = 4 + pssh_bytes.length
40
- length_prefix_bytes = int_to_four_bytes(length_including_prefix).bytes
35
+ length_prefix_bytes(pssh_bytes.length) + pssh_bytes
36
+ end
37
+
38
+ def self.version_bytes(pssh_version)
39
+ int_to_four_bytes(pssh_version << 24).bytes
40
+ end
41
+
42
+ def self.system_id_bytes(system_id)
43
+ uuid_to_bytes(system_id).bytes
44
+ end
45
+
46
+ def self.key_id_bytes(key_ids)
47
+ key_id_bytes = int_to_four_bytes(key_ids.length).bytes
48
+ key_ids.each do |key_id|
49
+ key_id_bytes += uuid_to_bytes(key_id).bytes
50
+ end
51
+ key_id_bytes
52
+ end
53
+
54
+ def self.pssh_data_bytes(pssh_data)
55
+ int_to_four_bytes(pssh_data.length).bytes + pssh_data
56
+ end
41
57
 
42
- length_prefix_bytes + pssh_bytes
58
+ def self.length_prefix_bytes(length)
59
+ length_including_prefix = 4 + length
60
+ int_to_four_bytes(length_including_prefix).bytes
43
61
  end
44
62
 
45
63
  def self.base64_encode_bytes(pssh_bytes)
@@ -1,3 +1,3 @@
1
1
  module PsshBox
2
- VERSION = '0.0.1'
2
+ VERSION = '0.1.0'
3
3
  end
data/pssh_box.gemspec CHANGED
@@ -1,32 +1,32 @@
1
- lib = File.expand_path('lib', __dir__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'pssh_box/version'
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = 'pssh_box'
7
- spec.version = PsshBox::VERSION
8
- spec.authors = ['Catalin Ursachi']
9
- spec.email = ['catalin.ursachi@softwire.com']
10
-
11
- spec.summary = 'A builder for PSSH boxes used in content encryption, as per the specification at'\
12
- ' https://w3c.github.io/encrypted-media/format-registry/initdata/cenc.html.'
13
- spec.homepage = 'https://github.com/catalin-ursachi/pssh_box'
14
- spec.license = 'MIT'
15
-
16
- spec.metadata['homepage_uri'] = spec.homepage
17
-
18
- # Specify which files should be added to the gem when it is released.
19
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
- end
23
- spec.bindir = 'exe'
24
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
- spec.require_paths = ['lib']
26
-
27
- spec.add_development_dependency 'bundler', '~> 2.0'
28
- spec.add_development_dependency 'rake', '~> 10.0'
29
- spec.add_development_dependency 'rspec', '~> 3.0'
30
-
31
- spec.add_dependency 'ruby-uuid', '~> 0.0.1'
32
- end
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'pssh_box/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'pssh_box'
7
+ spec.version = PsshBox::VERSION
8
+ spec.authors = ['Catalin Ursachi']
9
+ spec.email = ['catalin.ursachi@softwire.com']
10
+
11
+ spec.summary = 'A builder for PSSH boxes used in content encryption, as per the specification at'\
12
+ ' https://w3c.github.io/encrypted-media/format-registry/initdata/cenc.html.'
13
+ spec.homepage = 'https://github.com/catalin-ursachi/pssh_box'
14
+ spec.license = 'MIT'
15
+
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ spec.bindir = 'exe'
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ['lib']
26
+
27
+ spec.add_development_dependency 'bundler', '~> 2.0'
28
+ spec.add_development_dependency 'rake', '~> 10.0'
29
+ spec.add_development_dependency 'rspec', '~> 3.0'
30
+
31
+ spec.add_dependency 'ruby-uuid', '~> 0.0.1'
32
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pssh_box
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Catalin Ursachi