@@ -1295,9 +1295,9 @@ func (k *keyEd25519) Public() crypto.PublicKey {
1295
1295
return k .pub
1296
1296
}
1297
1297
1298
- func (k * keyEd25519 ) Sign (rand io.Reader , digest []byte , opts crypto.SignerOpts ) ([]byte , error ) {
1298
+ func (k * keyEd25519 ) Sign (rand io.Reader , message []byte , opts crypto.SignerOpts ) ([]byte , error ) {
1299
1299
return k .auth .do (k .yk , k .pp , func (tx * scTx ) ([]byte , error ) {
1300
- return ykSignEd25519 (tx , k .slot , k .pub , digest )
1300
+ return ykSignEd25519 (tx , k .slot , k .pub , message , opts )
1301
1301
})
1302
1302
}
1303
1303
@@ -1400,7 +1400,14 @@ func ykECDHX25519(tx *scTx, slot Slot, pub *ecdh.PublicKey, peer *ecdh.PublicKey
1400
1400
return sharedSecret , nil
1401
1401
}
1402
1402
1403
- func ykSignEd25519 (tx * scTx , slot Slot , pub ed25519.PublicKey , digest []byte ) ([]byte , error ) {
1403
+ func ykSignEd25519 (tx * scTx , slot Slot , pub ed25519.PublicKey , message []byte , opts crypto.SignerOpts ) ([]byte , error ) {
1404
+ if opts .HashFunc () != crypto .Hash (0 ) {
1405
+ return nil , fmt .Errorf ("ed25519ph not supported" )
1406
+ }
1407
+ if ed25519opts , ok := opts .(* ed25519.Options ); ok && ed25519opts .Context != "" {
1408
+ return nil , fmt .Errorf ("ed25519ctx not supported" )
1409
+ }
1410
+
1404
1411
// Adaptation of
1405
1412
// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-73-4.pdf#page=118
1406
1413
cmd := apdu {
@@ -1409,7 +1416,7 @@ func ykSignEd25519(tx *scTx, slot Slot, pub ed25519.PublicKey, digest []byte) ([
1409
1416
param2 : byte (slot .Key ),
1410
1417
data : marshalASN1 (0x7c ,
1411
1418
append ([]byte {0x82 , 0x00 },
1412
- marshalASN1 (0x81 , digest )... )),
1419
+ marshalASN1 (0x81 , message )... )),
1413
1420
}
1414
1421
resp , err := tx .Transmit (cmd )
1415
1422
if err != nil {
0 commit comments