cose 1.3.0 → 1.3.1

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
  SHA256:
3
- metadata.gz: 8a7da6d20b462494510800b95be262f6100a46b0b066c8255de6f1250a41429b
4
- data.tar.gz: a758caf5a05445bc36b4c8e2e64f562c181546eb9740d065e48d2c3c5ea22726
3
+ metadata.gz: 6611520d59f30093811ca400c7075f7ca90fdbec97faf316337690b8ae719ceb
4
+ data.tar.gz: a7602e083f00558c70008b0990f482162359e3beb8252c1cff689d8fe3bce8d5
5
5
  SHA512:
6
- metadata.gz: 47e4e46bb5e633a1e0eccb8fc9081411d1ff09439046f8ead15070aa2a2f3329d3b34e9744aa56a13a1cb0e6ff0490abc3148efe8e87d5d9efcaeb0f86fa514b
7
- data.tar.gz: 2bc529d8091353b0a90a7b04b8e33d490371bfc87c43149a977cde769234b69e9645d9ca8c5677088a91faef8630806c24435ad304551fe467dba4d0cd421971
6
+ metadata.gz: aa3f623c59b83397ff996d555de9244d1fc30ae3af8ca1546e6588dd71f0dda6e8f0095eb9c000657efcfb058de0be70b78ec649dc7489b8821522597fd2cf70
7
+ data.tar.gz: 7d8102ced4cafd52f3745c73d9bab50cf73f5f22920384f384f7a18d0113cf794f7639565143149790d6995d4ca04af6c6976b3d4b035a0e2f60388479270038
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [v1.3.1] - 2024-08-12
4
+
5
+ - Handling COSE EC keys encoded without leading 0 bytes in coordinates (#64). Credits to @waltercacau.
6
+
3
7
  ## [v1.3.0] - 2022-10-28
4
8
 
5
9
  - Add support for EdDSA (#55). Credits to @bdewater.
data/lib/cose/key/ec2.rb CHANGED
@@ -11,6 +11,8 @@ module COSE
11
11
 
12
12
  KTY_EC2 = 2
13
13
 
14
+ ZERO_BYTE = "\0".b
15
+
14
16
  def self.enforce_type(map)
15
17
  if map[LABEL_KTY] != KTY_EC2
16
18
  raise "Not an EC2 key"
@@ -68,7 +70,7 @@ module COSE
68
70
  def to_pkey
69
71
  if curve
70
72
  group = OpenSSL::PKey::EC::Group.new(curve.pkey_name)
71
- public_key_bn = OpenSSL::BN.new("\x04" + x + y, 2)
73
+ public_key_bn = OpenSSL::BN.new("\x04" + pad_coordinate(group, x) + pad_coordinate(group, y), 2)
72
74
  public_key_point = OpenSSL::PKey::EC::Point.new(group, public_key_bn)
73
75
 
74
76
  # RFC5480 SubjectPublicKeyInfo
@@ -113,6 +115,14 @@ module COSE
113
115
  def self.keyword_arguments_for_initialize(map)
114
116
  super.merge(y: map[LABEL_Y])
115
117
  end
118
+
119
+ def pad_coordinate(group, coordinate)
120
+ coordinate_length = (group.degree + 7) / 8
121
+ padding_required = coordinate_length - coordinate.length
122
+ return coordinate if padding_required <= 0
123
+
124
+ (ZERO_BYTE * padding_required) + coordinate
125
+ end
116
126
  end
117
127
  end
118
128
  end
data/lib/cose/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module COSE
4
- VERSION = "1.3.0"
4
+ VERSION = "1.3.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cose
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gonzalo Rodriguez
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-10-28 00:00:00.000000000 Z
12
+ date: 2024-08-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cbor
@@ -220,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
220
  - !ruby/object:Gem::Version
221
221
  version: '0'
222
222
  requirements: []
223
- rubygems_version: 3.2.32
223
+ rubygems_version: 3.5.3
224
224
  signing_key:
225
225
  specification_version: 4
226
226
  summary: Ruby implementation of RFC 8152 CBOR Object Signing and Encryption (COSE)