Merge pull request #11301 from miyazakh/f6776_3des

Documents a precondition in the signle-DES API
pull/11356/head
Sean Parkinson 2026-09-02 16:00:07 +10:00 committed by GitHub
commit 7bfdc9c793
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 24 additions and 1 deletions

View File

@ -7,6 +7,13 @@
yet been initialized. Note: If no iv is provided (i.e. iv == NULL)
the initialization vector defaults to an iv of 0.
\note This function must be called on a Des structure before it is
passed to wc_Des_CbcEncrypt(), wc_Des_CbcDecrypt(),
wc_Des_EcbEncrypt(), or wc_Des_EcbDecrypt(). Unlike the Des3 API,
the Des structure has no key-set state, so those functions do not
verify that a key has been set and will operate on undefined key
material if this precondition is not met.
\return 0 On successfully setting the key and initialization vector for
the Des structure
@ -70,6 +77,10 @@ void wc_Des_SetIV(Des* des, const byte* iv);
in the output buffer, out. It uses DES encryption with cipher block
chaining (CBC) mode.
\note wc_Des_SetKey() must be called on des before calling this
function. This function does not check whether a key has been set
and will encrypt using undefined key material if it has not.
\return 0 Returned upon successfully encrypting the given input message
\param des pointer to the Des structure to use for encryption
@ -103,6 +114,10 @@ int wc_Des_CbcEncrypt(Des* des, byte* out,
resulting plaintext in the output buffer, out. It uses DES encryption
with cipher block chaining (CBC) mode.
\note wc_Des_SetKey() must be called on des before calling this
function. This function does not check whether a key has been set
and will decrypt using undefined key material if it has not.
\return 0 Returned upon successfully decrypting the given ciphertext
\param des pointer to the Des structure to use for decryption
@ -136,6 +151,10 @@ int wc_Des_CbcDecrypt(Des* des, byte* out,
in the output buffer, out. It uses Des encryption with Electronic
Codebook (ECB) mode.
\note wc_Des_SetKey() must be called on des before calling this
function. This function does not check whether a key has been set
and will encrypt using undefined key material if it has not.
\return 0: Returned upon successfully encrypting the given plaintext.
\param des pointer to the Des structure to use for encryption
@ -156,7 +175,7 @@ int wc_Des_CbcDecrypt(Des* des, byte* out,
}
\endcode
\sa wc_Des_SetKe
\sa wc_Des_SetKey
*/
int wc_Des_EcbEncrypt(Des* des, byte* out,
const byte* in, word32 sz);
@ -350,6 +369,10 @@ int wc_Des3_CbcDecrypt(Des3* des, byte* out,
cases ECB mode is considered to be less secure. Please avoid using
ECB APIs directly whenever possible.
\note wc_Des_SetKey() must be called on des before calling this
function. This function does not check whether a key has been set
and will decrypt using undefined key material if it has not.
\return 0 On successfully decrypting the given ciphertext
\param des pointer to the Des structure to use for decryption