sandal 0.4.0 → 0.5.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/.travis.yml +0 -1
- data/CHANGELOG.md +14 -0
- data/README.md +1 -1
- data/lib/sandal.rb +77 -76
- data/lib/sandal/claims.rb +13 -13
- data/lib/sandal/enc.rb +15 -49
- data/lib/sandal/enc/acbc_hs.rb +97 -52
- data/lib/sandal/enc/agcm.rb +64 -26
- data/lib/sandal/enc/alg.rb +2 -3
- data/lib/sandal/enc/alg/direct.rb +27 -25
- data/lib/sandal/enc/alg/rsa.rb +82 -0
- data/lib/sandal/sig.rb +12 -12
- data/lib/sandal/sig/es.rb +43 -25
- data/lib/sandal/sig/hs.rb +21 -8
- data/lib/sandal/sig/rs.rb +34 -23
- data/lib/sandal/util.rb +7 -7
- data/lib/sandal/version.rb +1 -1
- data/spec/helper.rb +1 -0
- data/spec/sample_keys.rb +28 -0
- data/spec/sandal/claims_spec.rb +4 -4
- data/spec/sandal/enc/a128cbc_hs256_spec.rb +15 -39
- data/spec/sandal/enc/a128gcm_spec.rb +13 -6
- data/spec/sandal/enc/a256cbc_hs512_spec.rb +13 -4
- data/spec/sandal/enc/a256gcm_spec.rb +15 -37
- data/spec/sandal/enc/alg/direct_spec.rb +27 -33
- data/spec/sandal/enc/alg/rsa_spec.rb +100 -0
- data/spec/sandal/enc/shared_examples.rb +93 -21
- data/spec/sandal/sig/es_spec.rb +145 -188
- data/spec/sandal/sig/hs_spec.rb +73 -18
- data/spec/sandal/sig/rs_spec.rb +81 -78
- metadata +7 -6
- data/lib/sandal/enc/alg/rsa1_5.rb +0 -47
- data/lib/sandal/enc/alg/rsa_oaep.rb +0 -48
- data/spec/sandal/enc/alg/rsa1_5_spec.rb +0 -40
data/lib/sandal/sig.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
require
|
1
|
+
require "singleton"
|
2
2
|
|
3
3
|
module Sandal
|
4
4
|
# Contains signature (JWS) functionality.
|
5
5
|
module Sig
|
6
6
|
|
7
|
-
# The
|
7
|
+
# The "none" JWA signature method.
|
8
8
|
class None
|
9
9
|
include Singleton
|
10
10
|
|
11
|
-
#
|
12
|
-
|
11
|
+
# The JWA name of the algorithm.
|
12
|
+
NAME = "none"
|
13
13
|
|
14
|
-
#
|
15
|
-
def
|
16
|
-
|
14
|
+
# The JWA name of the algorithm.
|
15
|
+
def name
|
16
|
+
NAME
|
17
17
|
end
|
18
18
|
|
19
19
|
# Returns an empty signature.
|
@@ -21,12 +21,12 @@ module Sandal
|
|
21
21
|
# @param payload [String] This parameter is ignored.
|
22
22
|
# @return [String] An empty string.
|
23
23
|
def sign(payload)
|
24
|
-
|
24
|
+
""
|
25
25
|
end
|
26
26
|
|
27
27
|
# Validates that a signature is nil or empty.
|
28
28
|
#
|
29
|
-
# @param signature [String] The signature to
|
29
|
+
# @param signature [String] The signature to validate.
|
30
30
|
# @param payload [String] This parameter is ignored.
|
31
31
|
# @return [Boolean] true if the signature is nil/empty; otherwise false.
|
32
32
|
def valid?(signature, payload)
|
@@ -41,6 +41,6 @@ module Sandal
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
require
|
45
|
-
require
|
46
|
-
require
|
44
|
+
require "sandal/sig/es" unless RUBY_PLATFORM == "java"
|
45
|
+
require "sandal/sig/hs"
|
46
|
+
require "sandal/sig/rs"
|
data/lib/sandal/sig/es.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "openssl"
|
2
2
|
|
3
3
|
module Sandal
|
4
4
|
module Sig
|
@@ -6,18 +6,18 @@ module Sandal
|
|
6
6
|
# Base implementation of the ECDSA-SHA family of signature algorithms.
|
7
7
|
class ES
|
8
8
|
|
9
|
-
#
|
9
|
+
# The JWA name of the algorithm.
|
10
10
|
attr_reader :name
|
11
11
|
|
12
12
|
# Creates a new instance; it's probably easier to use one of the subclass
|
13
13
|
# constructors.
|
14
14
|
#
|
15
|
+
# @oaram name [String] The JWA name of the algorithm.
|
15
16
|
# @param sha_size [Integer] The size of the SHA algorithm.
|
16
17
|
# @param prime_size [Integer] The size of the ECDSA primes.
|
17
|
-
# @param key [OpenSSL::PKey::EC] The key to use for signing (private) or
|
18
|
-
|
19
|
-
|
20
|
-
@name = "ES#{sha_size}"
|
18
|
+
# @param key [OpenSSL::PKey::EC] The key to use for signing (private) or validation (public).
|
19
|
+
def initialize(name, sha_size, prime_size, key)
|
20
|
+
@name = name
|
21
21
|
@digest = OpenSSL::Digest.new("sha#{sha_size}")
|
22
22
|
@prime_size = prime_size
|
23
23
|
@key = key
|
@@ -36,7 +36,7 @@ module Sandal
|
|
36
36
|
|
37
37
|
# Validates a payload signature and returns whether the signature matches.
|
38
38
|
#
|
39
|
-
# @param signature [String] The signature to
|
39
|
+
# @param signature [String] The signature to validate.
|
40
40
|
# @param payload [String] The payload of the token.
|
41
41
|
# @return [Boolean] true if the signature is correct; otherwise false.
|
42
42
|
def valid?(signature, payload)
|
@@ -57,8 +57,8 @@ module Sandal
|
|
57
57
|
|
58
58
|
# Encodes a pair of BNs into an ASN.1 signature.
|
59
59
|
#
|
60
|
-
# @param r [OpenSSL::BN] The
|
61
|
-
# @param s [OpenSSL::BN] The
|
60
|
+
# @param r [OpenSSL::BN] The "r" value.
|
61
|
+
# @param s [OpenSSL::BN] The "s" value.
|
62
62
|
# @return [String] The ASN.1 signature.
|
63
63
|
def self.encode_asn1_signature(r, s)
|
64
64
|
items = [OpenSSL::ASN1::Integer.new(r), OpenSSL::ASN1::Integer.new(s)]
|
@@ -71,7 +71,7 @@ module Sandal
|
|
71
71
|
# @return [OpenSSL::BN, OpenSSL::BN] A pair of BNs.
|
72
72
|
def self.decode_jws_signature(signature)
|
73
73
|
n_length = signature.length / 2
|
74
|
-
s_to_n = -> s { OpenSSL::BN.new(s.unpack(
|
74
|
+
s_to_n = -> s { OpenSSL::BN.new(s.unpack("H*")[0], 16) }
|
75
75
|
r = s_to_n.call(signature[0..(n_length - 1)])
|
76
76
|
s = s_to_n.call(signature[n_length..-1])
|
77
77
|
return r, s
|
@@ -79,13 +79,13 @@ module Sandal
|
|
79
79
|
|
80
80
|
# Encodes a pair of BNs into a JWS signature.
|
81
81
|
#
|
82
|
-
# @param r [OpenSSL::BN] The
|
83
|
-
# @param s [OpenSSL::BN] The
|
82
|
+
# @param r [OpenSSL::BN] The "r" value.
|
83
|
+
# @param s [OpenSSL::BN] The "s" value.
|
84
84
|
# @param prime_size [Integer] The size of the ECDSA primes.
|
85
85
|
# @return [String] The ASN.1 signature.
|
86
86
|
def self.encode_jws_signature(r, s, prime_size)
|
87
87
|
byte_count = (prime_size / 8.0).ceil
|
88
|
-
n_to_s = -> n { [n.to_s(16)].pack(
|
88
|
+
n_to_s = -> n { [n.to_s(16)].pack("H*").rjust(byte_count, "\0") }
|
89
89
|
n_to_s.call(r) + n_to_s.call(s)
|
90
90
|
end
|
91
91
|
|
@@ -109,40 +109,58 @@ module Sandal
|
|
109
109
|
|
110
110
|
# The ECDSA-SHA256 signing algorithm.
|
111
111
|
class ES256 < Sandal::Sig::ES
|
112
|
+
|
113
|
+
# The JWA name of the algorithm.
|
114
|
+
NAME = "ES256"
|
115
|
+
|
116
|
+
# The ECDSA curve name.
|
117
|
+
CURVE_NAME = "prime256v1"
|
118
|
+
|
112
119
|
# Creates a new instance.
|
113
120
|
#
|
114
|
-
# @param key [OpenSSL::PKey::EC or String] The key to use for signing
|
115
|
-
#
|
116
|
-
# will be passed to the constructor of the EC class.
|
121
|
+
# @param key [OpenSSL::PKey::EC or String] The key to use for signing (private) or validation (public). If the
|
122
|
+
# value is a String then it will be passed to the constructor of the EC class.
|
117
123
|
# @raise [ArgumentError] The key is not in the "prime256v1" group.
|
118
124
|
def initialize(key)
|
119
|
-
super(256, 256, make_key(key,
|
125
|
+
super(NAME, 256, 256, make_key(key, CURVE_NAME))
|
120
126
|
end
|
121
127
|
end
|
122
128
|
|
123
129
|
# The ECDSA-SHA384 signing algorithm.
|
124
130
|
class ES384 < Sandal::Sig::ES
|
131
|
+
|
132
|
+
# The JWA name of the algorithm.
|
133
|
+
NAME = "ES384"
|
134
|
+
|
135
|
+
# The ECDSA curve name.
|
136
|
+
CURVE_NAME = "secp384r1"
|
137
|
+
|
125
138
|
# Creates a new instance.
|
126
139
|
#
|
127
|
-
# @param key [OpenSSL::PKey::EC or String] The key to use for signing
|
128
|
-
#
|
129
|
-
# will be passed to the constructor of the EC class.
|
140
|
+
# @param key [OpenSSL::PKey::EC or String] The key to use for signing (private) or validation (public). If the
|
141
|
+
# value is a String then it will be passed to the constructor of the EC class.
|
130
142
|
# @raise [ArgumentError] The key is not in the "secp384r1" group.
|
131
143
|
def initialize(key)
|
132
|
-
super(384, 384, make_key(key,
|
144
|
+
super(NAME, 384, 384, make_key(key, CURVE_NAME))
|
133
145
|
end
|
134
146
|
end
|
135
147
|
|
136
148
|
# The ECDSA-SHA512 signing algorithm.
|
137
149
|
class ES512 < Sandal::Sig::ES
|
150
|
+
|
151
|
+
# The JWA name of the algorithm.
|
152
|
+
NAME = "ES512"
|
153
|
+
|
154
|
+
# The ECDSA curve name.
|
155
|
+
CURVE_NAME = "secp521r1"
|
156
|
+
|
138
157
|
# Creates a new instance.
|
139
158
|
#
|
140
|
-
# @param key [OpenSSL::PKey::EC or String] The key to use for signing
|
141
|
-
#
|
142
|
-
# will be passed to the constructor of the EC class.
|
159
|
+
# @param key [OpenSSL::PKey::EC or String] The key to use for signing (private) or validation (public). If the
|
160
|
+
# value is a String then it will be passed to the constructor of the EC class.
|
143
161
|
# @raise [ArgumentError] The key is not in the "secp521r1" group.
|
144
162
|
def initialize(key)
|
145
|
-
super(512, 521, make_key(key,
|
163
|
+
super(NAME, 512, 521, make_key(key, CURVE_NAME))
|
146
164
|
end
|
147
165
|
end
|
148
166
|
|
data/lib/sandal/sig/hs.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "openssl"
|
2
2
|
|
3
3
|
module Sandal
|
4
4
|
module Sig
|
@@ -7,16 +7,17 @@ module Sandal
|
|
7
7
|
class HS
|
8
8
|
include Sandal::Util
|
9
9
|
|
10
|
-
#
|
10
|
+
# The JWA name of the algorithm.
|
11
11
|
attr_reader :name
|
12
12
|
|
13
13
|
# Creates a new instance; it's probably easier to use one of the subclass
|
14
14
|
# constructors.
|
15
15
|
#
|
16
|
+
# @oaram name [String] The JWA name of the algorithm.
|
16
17
|
# @param sha_size [Integer] The size of the SHA algorithm.
|
17
18
|
# @param key [String] The key to use for signing or validation.
|
18
|
-
def initialize(sha_size, key)
|
19
|
-
@name =
|
19
|
+
def initialize(name, sha_size, key)
|
20
|
+
@name = name
|
20
21
|
@digest = OpenSSL::Digest.new("sha#{sha_size}")
|
21
22
|
@key = key
|
22
23
|
end
|
@@ -31,7 +32,7 @@ module Sandal
|
|
31
32
|
|
32
33
|
# Validates a payload signature and returns whether the signature matches.
|
33
34
|
#
|
34
|
-
# @param signature [String] The signature to
|
35
|
+
# @param signature [String] The signature to validate.
|
35
36
|
# @param payload [String] The payload of the token.
|
36
37
|
# @return [Boolean] true if the signature is correct; otherwise false.
|
37
38
|
def valid?(signature, payload)
|
@@ -42,31 +43,43 @@ module Sandal
|
|
42
43
|
|
43
44
|
# The HMAC-SHA256 signing algorithm.
|
44
45
|
class HS256 < Sandal::Sig::HS
|
46
|
+
|
47
|
+
# The JWA name of the algorithm.
|
48
|
+
NAME = "HS256"
|
49
|
+
|
45
50
|
# Creates a new instance.
|
46
51
|
#
|
47
52
|
# @param key [String] The key to use for signing or validation.
|
48
53
|
def initialize(key)
|
49
|
-
super(256, key)
|
54
|
+
super(NAME, 256, key)
|
50
55
|
end
|
51
56
|
end
|
52
57
|
|
53
58
|
# The HMAC-SHA384 signing algorithm.
|
54
59
|
class HS384 < Sandal::Sig::HS
|
60
|
+
|
61
|
+
# The JWA name of the algorithm.
|
62
|
+
NAME = "HS384"
|
63
|
+
|
55
64
|
# Creates a new instance.
|
56
65
|
#
|
57
66
|
# @param key [String] The key to use for signing or validation.
|
58
67
|
def initialize(key)
|
59
|
-
super(384, key)
|
68
|
+
super(NAME, 384, key)
|
60
69
|
end
|
61
70
|
end
|
62
71
|
|
63
72
|
# The HMAC-SHA512 signing algorithm.
|
64
73
|
class HS512 < Sandal::Sig::HS
|
74
|
+
|
75
|
+
# The JWA name of the algorithm.
|
76
|
+
NAME = "HS512"
|
77
|
+
|
65
78
|
# Creates a new instance.
|
66
79
|
#
|
67
80
|
# @param key [String] The key to use for signing or validation.
|
68
81
|
def initialize(key)
|
69
|
-
super(512, key)
|
82
|
+
super(NAME, 512, key)
|
70
83
|
end
|
71
84
|
end
|
72
85
|
|
data/lib/sandal/sig/rs.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "openssl"
|
2
2
|
|
3
3
|
module Sandal
|
4
4
|
module Sig
|
@@ -6,18 +6,18 @@ module Sandal
|
|
6
6
|
# Base implementation of the RSA-SHA family of signature algorithms.
|
7
7
|
class RS
|
8
8
|
|
9
|
-
#
|
9
|
+
# The JWA name of the algorithm.
|
10
10
|
attr_reader :name
|
11
11
|
|
12
12
|
# Creates a new instance; it's probably easier to use one of the subclass
|
13
13
|
# constructors.
|
14
14
|
#
|
15
|
+
# @oaram name [String] The JWA name of the algorithm.
|
15
16
|
# @param sha_size [Integer] The size of the SHA algorithm.
|
16
|
-
# @param key [OpenSSL::PKey::RSA] The key to use for signing (private) or
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
@name = "RS#{sha_size}"
|
17
|
+
# @param key [OpenSSL::PKey::RSA] The key to use for signing (private) or validation (public). This must be at
|
18
|
+
# least 2048 bits to be compliant with the JWA specification.
|
19
|
+
def initialize(name, sha_size, key)
|
20
|
+
@name = name
|
21
21
|
@digest = OpenSSL::Digest.new("sha#{sha_size}")
|
22
22
|
@key = key
|
23
23
|
end
|
@@ -32,11 +32,13 @@ module Sandal
|
|
32
32
|
|
33
33
|
# Validates a payload signature and returns whether the signature matches.
|
34
34
|
#
|
35
|
-
# @param signature [String] The signature to
|
35
|
+
# @param signature [String] The signature to validate.
|
36
36
|
# @param payload [String] The payload of the token.
|
37
37
|
# @return [Boolean] true if the signature is correct; otherwise false.
|
38
38
|
def valid?(signature, payload)
|
39
39
|
@key.verify(@digest, signature, payload)
|
40
|
+
rescue OpenSSL::PKey::PKeyError # happens in jruby if the signature is invalid
|
41
|
+
false
|
40
42
|
end
|
41
43
|
|
42
44
|
private
|
@@ -53,40 +55,49 @@ module Sandal
|
|
53
55
|
|
54
56
|
# The RSA-SHA256 signing algorithm.
|
55
57
|
class RS256 < Sandal::Sig::RS
|
58
|
+
|
59
|
+
# The JWA name of the algorithm.
|
60
|
+
NAME = "RS256"
|
61
|
+
|
56
62
|
# Creates a new instance.
|
57
63
|
#
|
58
|
-
# @param key [OpenSSL::PKey::RSA or String] The key to use for signing
|
59
|
-
#
|
60
|
-
#
|
61
|
-
# least 2048 bits to be compliant with the JWA specification.
|
64
|
+
# @param key [OpenSSL::PKey::RSA or String] The key to use for signing (private) or validation (public). If the
|
65
|
+
# value is a String then it will be passed to the constructor of the RSA class. This must be at least 2048 bits
|
66
|
+
# to be compliant with the JWA specification.
|
62
67
|
def initialize(key)
|
63
|
-
super(256, make_key(key))
|
68
|
+
super(NAME, 256, make_key(key))
|
64
69
|
end
|
65
70
|
end
|
66
71
|
|
67
72
|
# The RSA-SHA384 signing algorithm.
|
68
73
|
class RS384 < Sandal::Sig::RS
|
74
|
+
|
75
|
+
# The JWA name of the algorithm.
|
76
|
+
NAME = "RS384"
|
77
|
+
|
69
78
|
# Creates a new instance.
|
70
79
|
#
|
71
|
-
# @param key [OpenSSL::PKey::RSA or String] The key to use for signing
|
72
|
-
#
|
73
|
-
#
|
74
|
-
# least 2048 bits to be compliant with the JWA specification.
|
80
|
+
# @param key [OpenSSL::PKey::RSA or String] The key to use for signing (private) or validation (public). If the
|
81
|
+
# value is a String then it will be passed to the constructor of the RSA class. This must be at least 2048 bits
|
82
|
+
# to be compliant with the JWA specification.
|
75
83
|
def initialize(key)
|
76
|
-
super(384, make_key(key))
|
84
|
+
super(NAME, 384, make_key(key))
|
77
85
|
end
|
78
86
|
end
|
79
87
|
|
80
88
|
# The RSA-SHA512 signing algorithm.
|
81
89
|
class RS512 < Sandal::Sig::RS
|
90
|
+
|
91
|
+
# The JWA name of the algorithm.
|
92
|
+
NAME = "RS512"
|
93
|
+
|
82
94
|
# Creates a new instance.
|
83
95
|
#
|
84
|
-
# @param key [OpenSSL::PKey::RSA or String] The key to use for signing
|
85
|
-
#
|
86
|
-
#
|
87
|
-
# least 2048 bits to be compliant with the JWA specification.
|
96
|
+
# @param key [OpenSSL::PKey::RSA or String] The key to use for signing (private) or validation (public). If the
|
97
|
+
# value is a String then it will be passed to the constructor of the RSA class. This must be at least 2048 bits
|
98
|
+
# to be compliant with the JWA specification.
|
88
99
|
def initialize(key)
|
89
|
-
super(512, make_key(key))
|
100
|
+
super(NAME, 512, make_key(key))
|
90
101
|
end
|
91
102
|
end
|
92
103
|
|
data/lib/sandal/util.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "base64"
|
2
2
|
|
3
3
|
module Sandal
|
4
4
|
# @private
|
@@ -30,7 +30,7 @@ module Sandal
|
|
30
30
|
# @param s [String] The string to encode.
|
31
31
|
# @return [String] The encoded base64 string.
|
32
32
|
def jwt_base64_encode(s)
|
33
|
-
Base64.urlsafe_encode64(s).gsub(/=+$/,
|
33
|
+
Base64.urlsafe_encode64(s).gsub(/=+$/, "")
|
34
34
|
end
|
35
35
|
|
36
36
|
# Base64 decodes a string, in compliance with the JWT specification.
|
@@ -39,21 +39,21 @@ module Sandal
|
|
39
39
|
# @return [String] The decoded string.
|
40
40
|
# @raise [ArgumentError] The base64 string is invalid or contains padding.
|
41
41
|
def jwt_base64_decode(s)
|
42
|
-
if s.end_with?(
|
43
|
-
raise ArgumentError,
|
42
|
+
if s.end_with?("=")
|
43
|
+
raise ArgumentError, "Base64 strings must not contain padding."
|
44
44
|
end
|
45
45
|
|
46
46
|
padding_length = (4 - (s.length % 4)) % 4
|
47
|
-
padding =
|
47
|
+
padding = "=" * padding_length
|
48
48
|
input = s + padding
|
49
49
|
result = Base64.urlsafe_decode64(input)
|
50
50
|
|
51
|
-
# this bit is primarily for jruby which does a
|
51
|
+
# this bit is primarily for jruby which does a "best effort" decode of
|
52
52
|
# whatever data it can if the input is invalid rather than raising an
|
53
53
|
# ArgumentError - as that could be a security issue we'll check that the
|
54
54
|
# result contains all the data that was in the input string
|
55
55
|
unless input.length == (((result.length - 1) / 3) * 4) + 4
|
56
|
-
raise ArgumentError,
|
56
|
+
raise ArgumentError, "Invalid base64."
|
57
57
|
end
|
58
58
|
|
59
59
|
result
|
data/lib/sandal/version.rb
CHANGED
data/spec/helper.rb
CHANGED
data/spec/sample_keys.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
module SampleKeys
|
3
|
+
|
4
|
+
def self.jwe_draft11_appendix1_rsa
|
5
|
+
key = OpenSSL::PKey::RSA.new(2048)
|
6
|
+
key.n = make_bn([161, 168, 84, 34, 133, 176, 208, 173, 46, 176, 163, 110, 57, 30, 135, 227, 9, 31, 226, 128, 84, 92, 116, 241, 70, 248, 27, 227, 193, 62, 5, 91, 241, 145, 224, 205, 141, 176, 184, 133, 239, 43, 81, 103, 9, 161, 153, 157, 179, 104, 123, 51, 189, 34, 152, 69, 97, 69, 78, 93, 140, 131, 87, 182, 169, 101, 92, 142, 3, 22, 167, 8, 212, 56, 35, 79, 210, 222, 192, 208, 252, 49, 109, 138, 173, 253, 210, 166, 201, 63, 102, 74, 5, 158, 41, 90, 144, 108, 160, 79, 10, 89, 222, 231, 172, 31, 227, 197, 0, 19, 72, 81, 138, 78, 136, 221, 121, 118, 196, 17, 146, 10, 244, 188, 72, 113, 55, 221, 162, 217, 171, 27, 57, 233, 210, 101, 236, 154, 199, 56, 138, 239, 101, 48, 198, 186, 202, 160, 76, 111, 234, 71, 57, 183, 5, 211, 171, 136, 126, 64, 40, 75, 58, 89, 244, 254, 107, 84, 103, 7, 236, 69, 163, 18, 180, 251, 58, 153, 46, 151, 174, 12, 103, 197, 181, 161, 162, 55, 250, 235, 123, 110, 17, 11, 158, 24, 47, 133, 8, 199, 235, 107, 126, 130, 246, 73, 195, 20, 108, 202, 176, 214, 187, 45, 146, 182, 118, 54, 32, 200, 61, 201, 71, 243, 1, 255, 131, 84, 37, 111, 211, 168, 228, 45, 192, 118, 27, 197, 235, 232, 36, 10, 230, 248, 190, 82, 182, 140, 35, 204, 108, 190, 253, 186, 186, 27])
|
7
|
+
key.e = make_bn([1, 0, 1])
|
8
|
+
key.d = make_bn([144, 183, 109, 34, 62, 134, 108, 57, 44, 252, 10, 66, 73, 54, 16, 181, 233, 92, 54, 219, 101, 42, 35, 178, 63, 51, 43, 92, 119, 136, 251, 41, 53, 23, 191, 164, 164, 60, 88, 227, 229, 152, 228, 213, 149, 228, 169, 237, 104, 71, 151, 75, 88, 252, 216, 77, 251, 231, 28, 97, 88, 193, 215, 202, 248, 216, 121, 195, 211, 245, 250, 112, 71, 243, 61, 129, 95, 39, 244, 122, 225, 217, 169, 211, 165, 48, 253, 220, 59, 122, 219, 42, 86, 223, 32, 236, 39, 48, 103, 78, 122, 216, 187, 88, 176, 89, 24, 1, 42, 177, 24, 99, 142, 170, 1, 146, 43, 3, 108, 64, 194, 121, 182, 95, 187, 134, 71, 88, 96, 134, 74, 131, 167, 69, 106, 143, 121, 27, 72, 44, 245, 95, 39, 194, 179, 175, 203, 122, 16, 112, 183, 17, 200, 202, 31, 17, 138, 156, 184, 210, 157, 184, 154, 131, 128, 110, 12, 85, 195, 122, 241, 79, 251, 229, 183, 117, 21, 123, 133, 142, 220, 153, 9, 59, 57, 105, 81, 255, 138, 77, 82, 54, 62, 216, 38, 249, 208, 17, 197, 49, 45, 19, 232, 157, 251, 131, 137, 175, 72, 126, 43, 229, 69, 179, 117, 82, 157, 213, 83, 35, 57, 210, 197, 252, 171, 143, 194, 11, 47, 163, 6, 253, 75, 252, 96, 11, 187, 84, 130, 210, 7, 121, 78, 91, 79, 57, 251, 138, 132, 220, 60, 224, 173, 56, 224, 201])
|
9
|
+
key
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.jwe_draft11_appendix2_rsa
|
13
|
+
key = OpenSSL::PKey::RSA.new(2048)
|
14
|
+
key.n = make_bn([177, 119, 33, 13, 164, 30, 108, 121, 207, 136, 107, 242, 12, 224, 19, 226, 198, 134, 17, 71, 173, 75, 42, 61, 48, 162, 206, 161, 97, 108, 185, 234, 226, 219, 118, 206, 118, 5, 169, 224, 60, 181, 90, 85, 51, 123, 6, 224, 4, 122, 29, 230, 151, 12, 244, 127, 121, 25, 4, 85, 220, 144, 215, 110, 130, 17, 68, 228, 129, 138, 7, 130, 231, 40, 212, 214, 17, 179, 28, 124, 151, 178, 207, 20, 14, 154, 222, 113, 176, 24, 198, 73, 211, 113, 9, 33, 178, 80, 13, 25, 21, 25, 153, 212, 206, 67, 154, 147, 70, 194, 192, 183, 160, 83, 98, 236, 175, 85, 23, 97, 75, 199, 177, 73, 145, 50, 253, 206, 32, 179, 254, 236, 190, 82, 73, 67, 129, 253, 252, 220, 108, 136, 138, 11, 192, 1, 36, 239, 228, 55, 81, 113, 17, 25, 140, 63, 239, 146, 3, 172, 96, 60, 227, 233, 64, 255, 224, 173, 225, 228, 229, 92, 112, 72, 99, 97, 26, 87, 187, 123, 46, 50, 90, 202, 117, 73, 10, 153, 47, 224, 178, 163, 77, 48, 46, 154, 33, 148, 34, 228, 33, 172, 216, 89, 46, 225, 127, 68, 146, 234, 30, 147, 54, 146, 5, 133, 45, 78, 254, 85, 55, 75, 213, 86, 194, 218, 215, 163, 189, 194, 54, 6, 83, 36, 18, 153, 53, 7, 48, 89, 35, 66, 144, 7, 65, 154, 13, 97, 75, 55, 230, 132, 3, 13, 239, 71])
|
15
|
+
key.e = make_bn([1, 0, 1])
|
16
|
+
key.d = make_bn([84, 80, 150, 58, 165, 235, 242, 123, 217, 55, 38, 154, 36, 181, 221, 156, 211, 215, 100, 164, 90, 88, 40, 228, 83, 148, 54, 122, 4, 16, 165, 48, 76, 194, 26, 107, 51, 53, 179, 165, 31, 18, 198, 173, 78, 61, 56, 97, 252, 158, 140, 80, 63, 25, 223, 156, 36, 203, 214, 252, 120, 67, 180, 167, 3, 82, 243, 25, 97, 214, 83, 133, 69, 16, 104, 54, 160, 200, 41, 83, 164, 187, 70, 153, 111, 234, 242, 158, 175, 28, 198, 48, 211, 45, 148, 58, 23, 62, 227, 74, 52, 117, 42, 90, 41, 249, 130, 154, 80, 119, 61, 26, 193, 40, 125, 10, 152, 174, 227, 225, 205, 32, 62, 66, 6, 163, 100, 99, 219, 19, 253, 25, 105, 80, 201, 29, 252, 157, 237, 69, 1, 80, 171, 167, 20, 196, 156, 109, 249, 88, 0, 3, 152, 38, 165, 72, 87, 6, 152, 71, 156, 214, 16, 71, 30, 82, 51, 103, 76, 218, 63, 9, 84, 163, 249, 91, 215, 44, 238, 85, 101, 240, 148, 1, 82, 224, 91, 135, 105, 127, 84, 171, 181, 152, 210, 183, 126, 24, 46, 196, 90, 173, 38, 245, 219, 186, 222, 27, 240, 212, 194, 15, 66, 135, 226, 178, 190, 52, 245, 74, 65, 224, 81, 100, 85, 25, 204, 165, 203, 187, 175, 84, 100, 82, 15, 11, 23, 202, 151, 107, 54, 41, 207, 3, 136, 229, 134, 131, 93, 139, 50, 182, 204, 93, 130, 89])
|
17
|
+
key
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.jws_draft11_appendix2_rsa
|
21
|
+
key = OpenSSL::PKey::RSA.new(2048)
|
22
|
+
key.n = make_bn([161, 248, 22, 10, 226, 227, 201, 180, 101, 206, 141, 45, 101, 98, 99, 54, 43, 146, 125, 190, 41, 225, 240, 36, 119, 252, 22, 37, 204, 144, 161, 54, 227, 139, 217, 52, 151, 197, 182, 234, 99, 221, 119, 17, 230, 124, 116, 41, 249, 86, 176, 251, 138, 143, 8, 154, 220, 75, 105, 137, 60, 193, 51, 63, 83, 237, 208, 25, 184, 119, 132, 37, 47, 236, 145, 79, 228, 133, 119, 105, 89, 75, 234, 66, 128, 211, 44, 15, 85, 191, 98, 148, 79, 19, 3, 150, 188, 110, 155, 223, 110, 189, 210, 189, 163, 103, 142, 236, 160, 198, 104, 247, 1, 179, 141, 191, 251, 56, 200, 52, 44, 226, 254, 109, 39, 250, 222, 74, 90, 72, 116, 151, 157, 212, 185, 207, 154, 222, 196, 199, 91, 5, 133, 44, 44, 15, 94, 248, 165, 193, 117, 3, 146, 249, 68, 232, 237, 100, 193, 16, 198, 182, 71, 96, 154, 164, 120, 58, 235, 156, 108, 154, 215, 85, 49, 48, 80, 99, 139, 131, 102, 92, 111, 111, 122, 130, 163, 150, 112, 42, 31, 100, 27, 130, 211, 235, 242, 57, 34, 25, 73, 31, 182, 134, 135, 44, 87, 22, 245, 10, 248, 53, 141, 154, 139, 157, 23, 195, 64, 114, 143, 127, 135, 216, 154, 24, 216, 252, 171, 103, 173, 132, 89, 12, 46, 207, 117, 147, 57, 54, 60, 7, 3, 77, 111, 96, 111, 158, 33, 224, 84, 86, 202, 229, 233, 161])
|
23
|
+
key.e = make_bn([1, 0, 1])
|
24
|
+
key.d = make_bn([18, 174, 113, 164, 105, 205, 10, 43, 195, 126, 82, 108, 69, 0, 87, 31, 29, 97, 117, 29, 100, 233, 73, 112, 123, 98, 89, 15, 157, 11, 165, 124, 150, 60, 64, 30, 63, 207, 47, 44, 211, 189, 236, 136, 229, 3, 191, 198, 67, 155, 11, 40, 200, 47, 125, 55, 151, 103, 31, 82, 19, 238, 216, 193, 90, 37, 216, 213, 206, 160, 2, 94, 227, 171, 46, 139, 127, 121, 33, 111, 198, 59, 234, 86, 39, 83, 180, 6, 68, 198, 161, 81, 39, 217, 178, 149, 69, 64, 160, 187, 225, 163, 5, 86, 152, 45, 78, 159, 222, 95, 100, 37, 241, 77, 75, 113, 52, 65, 181, 93, 199, 59, 155, 74, 237, 204, 146, 172, 227, 146, 126, 55, 245, 125, 12, 253, 94, 117, 129, 250, 81, 44, 143, 73, 97, 169, 235, 11, 128, 248, 168, 7, 70, 114, 138, 85, 255, 70, 71, 31, 52, 37, 6, 59, 157, 83, 100, 47, 94, 222, 30, 132, 214, 19, 8, 26, 250, 92, 34, 208, 81, 40, 91, 214, 59, 148, 59, 86, 93, 137, 138, 5, 104, 84, 19, 229, 60, 60, 108, 101, 37, 255, 31, 227, 78, 61, 220, 112, 240, 213, 100, 80, 253, 164, 139, 161, 46, 16, 78, 157, 235, 159, 184, 24, 129, 225, 196, 189, 242, 93, 146, 71, 244, 80, 200, 101, 146, 121, 104, 231, 115, 52, 244, 65, 79, 117, 167, 80, 225, 57, 84, 110, 58, 138, 115, 157])
|
25
|
+
key
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|