You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ce18c33
Browse filesBrowse the repository at this point in the historyBrowse files
fix(rsa,hmac): validate PSS salt and _GENERAL MAC lengths; SHA-384 block size (#166)
* refactor(attributes): deprecate Cka* in favour of the binding's CKA_* constants
crypto11's Cka* list was copied by hand before the move to pkcs11-go
and covers 111 of the 160 attributes in the PKCS#11 v3.2 header. The
binding's cryptoki package is generated from that header and defines
all of them, CKA_UNIQUE_ID, CKA_SEED and CKA_PUBLIC_CRC64_VALUE
included.
Each Cka* constant is now defined from the binding's constant of the
same name, keeping its AttributeType type, and the group is marked
deprecated so staticcheck and gopls point callers at pkcs11.CKA_*.
Existing code compiles and behaves as before. crypto11 itself uses
the binding's constants throughout; error messages and the names
AttributeSet.String prints are unchanged.
The unexported ckfArrayAttribute constant is gone, along with the
attributeTypeString case for that bare flag, which is not an
attribute.
AttributeSet.String keeps its own name table until a pkcs11-go
release provides cryptoki.AttributeName.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Nicolas-Peiffer <102670102+Nicolas-Peiffer@users.noreply.github.com>
* fix(rsa,hmac): validate PSS salt and _GENERAL MAC lengths; SHA-384 block size
RSA-PSS:
- A negative PSSOptions.SaltLength other than the Auto and
EqualsHash sentinels reached pkcs11-go's NewPSSParams, which panics
on a negative salt, so Sign panicked instead of returning an error.
It is now an error wrapping errUnsupportedRSAOptions.
- An explicit salt longer than the modulus can carry is
rsa.ErrMessageTooLong, as in crypto/rsa.
- A digest whose length is not the hash's size is an error, as on
the PKCS#1 v1.5 path, instead of being left to the token.
The resolution lives in pssSaltLength, tested without a token, and
each check has an integration subtest asserting an error and no panic.
HMAC:
- hmacInfos listed SHA-384 with a 64-byte block; it is 128.
- NewHMAC accepted any _GENERAL output length. Zero made every Sum
panic on the empty MAC, and a negative length reached the token as
a huge CK_ULONG. Lengths outside 1..full size are now rejected with
errInvalidMACLength before a session is taken.
TestHmacInfoSizesMatchDigests now checks every entry's size, block
size and _GENERAL flag against Go's own hash implementations.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Nicolas-Peiffer <102670102+Nicolas-Peiffer@users.noreply.github.com>
---------
Signed-off-by: Nicolas-Peiffer <102670102+Nicolas-Peiffer@users.noreply.github.com>
0 commit comments