Skip to content

Commit

Permalink
pkcs11-tool.c calculate size in bits for eddsa and xeddsa CDA_EC_POINT
Browse files Browse the repository at this point in the history
CKA_EC_POINT for eddsa and xeddsa are bit strings.

 On branch X25519-improvements-2
 Changes to be committed:
	modified:   tools/pkcs11-tool.c
  • Loading branch information
dengert committed Jan 20, 2024
1 parent 9137a8f commit 8a71e28
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/tools/pkcs11-tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -5134,8 +5134,17 @@ show_key(CK_SESSION_HANDLE sess, CK_OBJECT_HANDLE obj)
else
ksize = (size - 5) * 4;
} else {
/* This should be 255 for ed25519 and 448 for ed448 curves so roughly */
ksize = size * 8;
/*
* EDDSA and XEDDSA in PKCS11 are in bit strings.
* need to drop '03' tag, len (in bytes) and 00 bits in last byte.
*/
if ((size - 3) < 127)
ksize = (size - 3) * 8;
else if ((size - 4) <= 255)
ksize = (size - 4) * 8;
else
ksize = (size - 5) * 8;

}

printf(" EC_POINT %u bits\n", ksize);
Expand Down

0 comments on commit 8a71e28

Please sign in to comment.