jwk 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jwk/asn1.rb +14 -0
- data/lib/jwk/version.rb +1 -1
- data/spec/jwk/asn1_spec.rb +10 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0075ad292467ceea1135ce68aa74692a5cd4d310
|
4
|
+
data.tar.gz: 60c2de19b4b277f4a5174199d2834c59b30af298
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8eeb3928193130b35d4ce069691458584964d66848a9698ce9f8f67a9129afc57c6f2d6a2d63dfd3e7647940862f8057932caa87431217c2f7c2964d569fd02f
|
7
|
+
data.tar.gz: f26a41c3204cb59b4f5fe639d37743bed013eb5a6b0058c5fbad17f91e1a14be5862f4d055ba7d205e907008338ff276a2ca95695b8602aaef9074995843fd87
|
data/lib/jwk/asn1.rb
CHANGED
@@ -15,6 +15,9 @@ module JWK
|
|
15
15
|
_, raw_x = raw_integer_encoding(x)
|
16
16
|
_, raw_y = raw_integer_encoding(y)
|
17
17
|
|
18
|
+
raw_x = pad_coord_for_crv(crv, raw_x)
|
19
|
+
raw_y = pad_coord_for_crv(crv, raw_y)
|
20
|
+
|
18
21
|
object_id = object_id_for_crv(crv)
|
19
22
|
|
20
23
|
sequence(
|
@@ -38,6 +41,17 @@ module JWK
|
|
38
41
|
end
|
39
42
|
end
|
40
43
|
|
44
|
+
def pad_coord_for_crv(crv, coord)
|
45
|
+
case crv
|
46
|
+
when 'P-256'
|
47
|
+
coord.rjust(32, "\x00")
|
48
|
+
when 'P-384'
|
49
|
+
coord.rjust(48, "\x00")
|
50
|
+
when 'P-521'
|
51
|
+
coord.rjust(64, "\x00")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
41
55
|
def rsa_header
|
42
56
|
"\x30\x0D\x06\x09\x2A\x86\x48\x86\xF7\x0D\x01\x01\x01\x05\x00".force_encoding('ASCII-8BIT')
|
43
57
|
end
|
data/lib/jwk/version.rb
CHANGED
data/spec/jwk/asn1_spec.rb
CHANGED
@@ -41,15 +41,22 @@ describe JWK::ASN1 do
|
|
41
41
|
|
42
42
|
describe '.ec_private_key' do
|
43
43
|
let(:known_p256_asn) do
|
44
|
-
Base64.decode64('
|
44
|
+
Base64.decode64('MFgCAQEEAaCgCgYIKoZIzj0DAQehRANCAAQAAAAAAAAAAAAAAAAAAAAA' +
|
45
|
+
'AAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
|
46
|
+
'AAAAAAAD')
|
45
47
|
end
|
46
48
|
|
47
49
|
let(:known_p384_asn) do
|
48
|
-
Base64.decode64('
|
50
|
+
Base64.decode64('MHUCAQEEAaCgBwYFK4EEACKhZANiAAQAAAAAAAAAAAAAAAAAAAAAAAAA' +
|
51
|
+
'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAA' +
|
52
|
+
'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM=')
|
49
53
|
end
|
50
54
|
|
51
55
|
let(:known_p521_asn) do
|
52
|
-
Base64.decode64('
|
56
|
+
Base64.decode64('MIGXAgEBBAGgoAcGBSuBBAAjoYGFA4GCAAQAAAAAAAAAAAAAAAAAAAAA' +
|
57
|
+
'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
|
58
|
+
'AAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
|
59
|
+
'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAw==')
|
53
60
|
end
|
54
61
|
|
55
62
|
it 'generates valid ASN1 for a P-256 EC Private Key' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jwk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Boffa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|