certificate-transparency 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11f886387e3fe45724a6bfba907989cf2a947511
4
- data.tar.gz: 2cd7d9db7a182db68e07ebb2b6eae5de0a002e14
3
+ metadata.gz: 9d4d276d39e865c024a5ceada2a373fa28a6e000
4
+ data.tar.gz: d4fdbbbbb5370044a45e0b142a3b53bbe6f0bf71
5
5
  SHA512:
6
- metadata.gz: a686b0ea5debd3874535bbd71041b4e03ac57407ac2e8c6c19ae027b48e04f67520a13668468b7b6293bd1707df75669447858eb26d341061e6ea26703543bf0
7
- data.tar.gz: e687144e67b46d75ffe422f0b3693f061f65a00958746eee335d041be5ec4d28db077e33238e49cb23659de8e9bad50d53759ac9af5bed7a31c29d12915919d5
6
+ metadata.gz: bdc16768f058da4261e5847c0d7eaffd0b2fd239184bd213cb4f5d22f095f3a98b7adc4039beb373b80aecf064857820c323141929872f133aae73c6464f1841
7
+ data.tar.gz: c436c791481f67c184359634609d89c9a9989d529fda9c21487dd4033a889b022549d58bd3c550a4e5d4e53e57f793b1731844d2ac311b53207e7bbca4fc7da3
@@ -0,0 +1,43 @@
1
+ require 'json'
2
+ require 'tls'
3
+
4
+ # An element of a CT get-entries array (RFC6962 s4.6). Note that this is
5
+ # **not** the `LogEntry` type defined in RFC6962 s3.1, because that type is
6
+ # never actually used anywhere, so I stole its name.
7
+ #
8
+ class CertificateTransparency::LogEntry
9
+ attr_accessor :leaf_input
10
+ attr_accessor :extra_data
11
+
12
+ # Create a new LogEntry instance from a single member of the
13
+ # `"entries"` array returned by `/ct/v1/get-entries`.
14
+ #
15
+ def self.from_json(json)
16
+ doc = JSON.parse(json)
17
+
18
+ self.new.tap do |sth|
19
+ le_blob = doc["leaf_input"].unpack("m").first
20
+ sth.leaf_input = CT::MerkleTreeLeaf.from_blob(le_blob)
21
+
22
+ sth.extra_data = []
23
+ ed_blob = doc["extra_data"].unpack("m").first
24
+ if sth.leaf_input.timestamped_entry.entry_type == :precert_entry
25
+ pre_cert_blob, ed_blob = TLS::Opaque.from_blob(ed_blob, 2**24-1)
26
+
27
+ sth.extra_data << OpenSSL::X509::Certificate.new(pre_cert_blob.value)
28
+ end
29
+
30
+ ed_blob, rest = TLS::Opaque.from_blob(ed_blob, 2**24-1)
31
+ unless rest.empty?
32
+ raise ArgumentError,
33
+ "Unexpected garbage after certificate_chain: #{rest.inspect}"
34
+ end
35
+
36
+ ed_blob = ed_blob.value
37
+ until ed_blob.empty?
38
+ cert_blob, ed_blob = TLS::Opaque.from_blob(ed_blob, 2**24-1)
39
+ sth.extra_data << OpenSSL::X509::Certificate.new(cert_blob.value)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -31,6 +31,7 @@ end
31
31
  require_relative 'certificate-transparency/extensions/string'
32
32
  require_relative 'certificate-transparency/extensions/time'
33
33
 
34
+ require_relative 'certificate-transparency/log_entry'
34
35
  require_relative 'certificate-transparency/merkle_tree_leaf'
35
36
  require_relative 'certificate-transparency/pre_cert'
36
37
  require_relative 'certificate-transparency/signed_tree_head'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: certificate-transparency
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Palmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-01 00:00:00.000000000 Z
11
+ date: 2015-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -159,6 +159,7 @@ files:
159
159
  - lib/certificate-transparency.rb
160
160
  - lib/certificate-transparency/extensions/string.rb
161
161
  - lib/certificate-transparency/extensions/time.rb
162
+ - lib/certificate-transparency/log_entry.rb
162
163
  - lib/certificate-transparency/merkle_tree_leaf.rb
163
164
  - lib/certificate-transparency/pre_cert.rb
164
165
  - lib/certificate-transparency/signed_tree_head.rb