softhsm2-util AES key import fails whenever a newline character is present in file
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 52/100
Direzione di ricerca
Read the two cited entry points, src/bin/util/softhsm2-util-ossl.cpp and src/bin/util/softhsm2-util-botan.cpp, where the issue identifies fgets and strlen in binary key handling. Check how each path reads the key and determines its length, then reproduce with the provided 32-byte key containing 0A. Done means imports preserve all 32 bytes in both paths; the issue is stale because its last comment was 918 days ago.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I have just ran into an obscure problem where softhsm2-util --import --aes results in a (seemingly) succesful import of an AES key into SoftHSM v2, but actually has an incorrect AES key length. This results in a corrupted AES key that cannot be used.
The test case was a 32-byte (AES-256) secret key while the import listed by PKCS#11 (pkcs11-tool) resulted in an AES key with a length less than 32 bytes.
For example, the following key will result in an incorrect AES key length of 25 (notice the 0A newline character):
echo 2BC9931E0E50B4F6995CF194321D7DDDB91FA104925B6F8A0AFBAEF0207BB612 | xxd -r -p - > p.key
While looking at the relevant source code, I noticed that fgets and strlen are used to read out the binary key file:
- https://github.com/opendnssec/SoftHSMv2/blob/913e7bfd463194fadcdd28f578087cc9c15643ee/src/bin/util/softhsm2-util-ossl.cpp#L92
- https://github.com/opendnssec/SoftHSMv2/blob/913e7bfd463194fadcdd28f578087cc9c15643ee/src/bin/util/softhsm2-util-botan.cpp#L79
This is incorrect behaviour as the C function fgets is intended for text strings, not binary strings, and stops whenever a newline character is encountered (even though the file is opened with rb attributes) leading to a silent corruption of the key. fread should probably be used instead to properly read the key in all conditions.
Furthermore, strlen is used in a similar manner to determine the AES key length, as if it were a text string while it is actually a binary byte array. As far as I know and have tested, the CKA_VALUE expects a byte array.
- Lingua principale
- C++
- Stelle
- 1.1k
- Fork
- 434
- Merge medio
- 12g 14h
- PR unite (30g)
- 2
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di softhsm/SoftHSMv2
-
C_DigestKey digests a sensitive EC private key's CKA_VALUE: no check that the object is a secret keyAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 54/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 56/100
Tutte le issue di softhsm/SoftHSMv2
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
charmplusplus/charm#4210 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
[BUG] VPN auth dialog spawned by the secret agent fails with "TLS support is not available" on NixOSApertabug nixos umbriel
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
noctalia-dev/noctalia#5310 ·
I maintainer di solito rispondono entro 1 giorno
-
area/docdb kind/bug priority/medium status/awaiting-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
yugabyte/yugabyte-db#37426 ·
I maintainer di solito rispondono entro 1 giorno
-
[Engine] Two prompt block scorers enabled at once: WMMA silently wins and no log line is printedAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Niko1221/Strata#5693 · 2 commenti ·
I maintainer di solito rispondono entro 4 giorni