diff --git a/src/tools/pkcs11-tool.c b/src/tools/pkcs11-tool.c index 0ae694ad7d7..1eb0e0beb3d 100644 --- a/src/tools/pkcs11-tool.c +++ b/src/tools/pkcs11-tool.c @@ -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);