Skip to content

Commit 11e37e7

Browse files
committed
Fixed EC Attributes returned and enabled test cases for this.
1 parent 4f5c57a commit 11e37e7

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

pkcs11/util/ec.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ def decode_ec_private_key(der):
8181
return {
8282
Attribute.KEY_TYPE: KeyType.EC,
8383
Attribute.CLASS: ObjectClass.PRIVATE_KEY,
84-
Attribute.EC_PARAMS: asn1['parameters'].dump(),
85-
Attribute.VALUE: asn1['private_key'],
84+
Attribute.EC_PARAMS: asn1['parameters'].chosen.dump(),
85+
Attribute.VALUE: asn1['private_key'].contents,
8686
}
8787

8888

tests/test_ecc.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,9 @@ def test_import_key_pair(self):
143143
""")
144144
pub = self.session.create_object(decode_ec_public_key(pub))
145145

146-
# FIXME: why can't I sign this?
147-
# signature = priv.sign(b'Example', mechanism=Mechanism.ECDSA)
148-
# self.assertTrue(pub.verify(b'Example', signature,
149-
# mechanism=Mechanism.ECDSA))
146+
signature = priv.sign(b'Example', mechanism=Mechanism.ECDSA)
147+
self.assertTrue(pub.verify(b'Example', signature,
148+
mechanism=Mechanism.ECDSA))
150149

151150
@requires(Mechanism.EC_EDWARDS_KEY_PAIR_GEN, Mechanism.EDDSA)
152151
def test_sign_eddsa(self):
@@ -162,4 +161,3 @@ def test_sign_eddsa(self):
162161
data = b'HI BOB!'
163162
eddsa = priv.sign(data, mechanism=mechanism)
164163
self.assertTrue(pub.verify(data, eddsa, mechanism=mechanism))
165-

0 commit comments

Comments
 (0)