poly_pseudo 0.1.4 → 0.2.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 +4 -4
- data/lib/poly_pseudo/identity.rb +15 -0
- data/lib/poly_pseudo/pseudo_id.rb +8 -17
- data/lib/poly_pseudo/pseudonym.rb +15 -0
- data/lib/poly_pseudo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d249e4591da0413414ed62b3acc5d092ba82abe6e680a285510ff4e32bbbdab
|
4
|
+
data.tar.gz: c879e52bd77278d75f175d3be05f12657ed8ac1154d250d80d6c1cb6c5c71b0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c705f80284dde04eed0d3c965b2162f47faafd4bd329ddf68cb2878d5cfb270071eec8de6cc343ec793c48e23594017622a92163ba0b438431cab4c264515a67
|
7
|
+
data.tar.gz: f03bda21cccb82709652f94bb384467103cf6dc513df5c06aee72b4055fc2e4865c1e1d3c861da2eeb39175aea2116948b4b58c8eb93c578294861ff4891861d
|
data/lib/poly_pseudo/identity.rb
CHANGED
@@ -2,6 +2,21 @@ module PolyPseudo
|
|
2
2
|
class Identity
|
3
3
|
include PolyPseudo::PseudoId
|
4
4
|
|
5
|
+
def self.from_asn1(asn1)
|
6
|
+
attributes = {}
|
7
|
+
attributes["Type"] = asn1.value[0].value.to_s
|
8
|
+
attributes["SchemaVersion"] = asn1.value[1].value.to_i
|
9
|
+
attributes["SchemaKeyVersion"] = asn1.value[2].value.to_i
|
10
|
+
attributes["Creator"] = asn1.value[3].value.to_s
|
11
|
+
attributes["Recipient"] = asn1.value[4].value.to_s
|
12
|
+
attributes["RecipientKeySetVersion"] = asn1.value[5].value.to_i
|
13
|
+
attributes["Point1"] = OpenSSL::PKey::EC::Point.new(PolyPseudo.config.group, OpenSSL::BN.new(asn1.value[6].value[0].value, 2))
|
14
|
+
attributes["Point2"] = OpenSSL::PKey::EC::Point.new(PolyPseudo.config.group, OpenSSL::BN.new(asn1.value[6].value[1].value, 2))
|
15
|
+
attributes["Point3"] = OpenSSL::PKey::EC::Point.new(PolyPseudo.config.group, OpenSSL::BN.new(asn1.value[6].value[2].value, 2))
|
16
|
+
|
17
|
+
new(attributes)
|
18
|
+
end
|
19
|
+
|
5
20
|
# @param [PolyPseudo::Key] key
|
6
21
|
def decrypt(key)
|
7
22
|
PolyPseudo.init!
|
@@ -1,26 +1,17 @@
|
|
1
1
|
module PolyPseudo
|
2
2
|
module PseudoId
|
3
3
|
def self.from_asn1(encoded)
|
4
|
-
|
5
|
-
asn1 = OpenSSL::ASN1.decode(Base64.decode64(encoded))
|
6
|
-
attributes["Type"] = asn1.value[0].value.to_s
|
7
|
-
attributes["SchemaVersion"] = asn1.value[1].value.to_i
|
8
|
-
attributes["SchemaKeyVersion"] = asn1.value[2].value.to_i
|
9
|
-
attributes["Creator"] = asn1.value[3].value.to_s
|
10
|
-
attributes["Recipient"] = asn1.value[4].value.to_s
|
11
|
-
attributes["RecipientKeySetVersion"] = asn1.value[5].value.to_i
|
12
|
-
attributes["Point1"] = OpenSSL::PKey::EC::Point.new(PolyPseudo.config.group,
|
13
|
-
OpenSSL::BN.new(asn1.value[6].value[0].value, 2))
|
14
|
-
attributes["Point2"] = OpenSSL::PKey::EC::Point.new(PolyPseudo.config.group,
|
15
|
-
OpenSSL::BN.new(asn1.value[6].value[1].value, 2))
|
16
|
-
attributes["Point3"] = OpenSSL::PKey::EC::Point.new(PolyPseudo.config.group,
|
17
|
-
OpenSSL::BN.new(asn1.value[6].value[2].value, 2))
|
4
|
+
asn1 = OpenSSL::ASN1.decode(Base64.decode64(encoded))
|
18
5
|
|
19
|
-
case
|
6
|
+
case asn1.value[0].value.to_s
|
20
7
|
when /\A.*1\.2\.1\Z/
|
21
|
-
Identity.
|
8
|
+
Identity.from_asn1(asn1)
|
22
9
|
when /\A.*1\.2\.2\Z/
|
23
|
-
Pseudonym.
|
10
|
+
Pseudonym.from_asn1(asn1)
|
11
|
+
when /\A.*1\.2\.3\Z/
|
12
|
+
Identity.from_asn1(asn1.value[1].value[0])
|
13
|
+
when /\A.*1\.2\.4\Z/
|
14
|
+
Pseudonym.from_asn1(asn1.value[1].value[0])
|
24
15
|
else
|
25
16
|
raise "Invalid type"
|
26
17
|
end
|
@@ -2,6 +2,21 @@ module PolyPseudo
|
|
2
2
|
class Pseudonym
|
3
3
|
include PolyPseudo::PseudoId
|
4
4
|
|
5
|
+
def self.from_asn1(asn1)
|
6
|
+
attributes = {}
|
7
|
+
attributes["Type"] = asn1.value[0].value.to_s
|
8
|
+
attributes["SchemaVersion"] = asn1.value[1].value.to_i
|
9
|
+
attributes["SchemaKeyVersion"] = asn1.value[2].value.to_i
|
10
|
+
attributes["Creator"] = asn1.value[3].value.to_s
|
11
|
+
attributes["Recipient"] = asn1.value[4].value.to_s
|
12
|
+
attributes["RecipientKeySetVersion"] = asn1.value[5].value.to_i
|
13
|
+
attributes["Point1"] = OpenSSL::PKey::EC::Point.new(PolyPseudo.config.group, OpenSSL::BN.new(asn1.value[7].value[0].value, 2))
|
14
|
+
attributes["Point2"] = OpenSSL::PKey::EC::Point.new(PolyPseudo.config.group, OpenSSL::BN.new(asn1.value[7].value[1].value, 2))
|
15
|
+
attributes["Point3"] = OpenSSL::PKey::EC::Point.new(PolyPseudo.config.group, OpenSSL::BN.new(asn1.value[7].value[2].value, 2))
|
16
|
+
|
17
|
+
new(attributes)
|
18
|
+
end
|
19
|
+
|
5
20
|
# @param [PolyPseudo::Key] closing_key
|
6
21
|
def decrypt(decryption_key, closing_key)
|
7
22
|
PolyPseudo.init!
|
data/lib/poly_pseudo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poly_pseudo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benoist Claassen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|