Skip to content

Commit 6f506cb

Browse files
committed
Update docs
Signed-off-by: Steffen Jaeckel <[email protected]>
1 parent 609d4f3 commit 6f506cb

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

doc/crypt.tex

+24-3
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ \subsection{Simple Encryption Demonstration}
620620
(only on x86 with SSE4.1) &&&&& \\
621621
\hline Twofish & twofish\_desc & 16 & 16, 24, 32 & 16 & 7 \\
622622
\hline DES & des\_desc & 8 & 8 & 16 & 13 \\
623+
\hline DES-X & desx\_desc & 8 & 24 & 24 & 27 \\
623624
\hline 3DES (EDE mode) & des3\_desc & 8 & 16, 24 & 16 & 14 \\
624625
\hline CAST5 (CAST-128) & cast5\_desc & 8 & 5 $\ldots$ 16 & 12, 16 & 15 \\
625626
\hline Noekeon & noekeon\_desc & 16 & 16 & 16 & 16 \\
@@ -8028,16 +8029,31 @@ \subsection{Depadding}
80288029
The following struct is used in various parts of the library that deals with user-passwords.
80298030

80308031
\begin{verbatim}
8031-
typedef struct {
8032+
typedef struct password_ctx {
80328033
/**
80338034
Callback function that is called when a password is required.
80348035
8036+
Please be aware that the library takes ownership of the pointer that is
8037+
returned to the library via `str`.
8038+
The data will be zeroed and `free()`'d as soon as it isn't required anymore.
8039+
c.f. the documentation of the `free()` function pointer for details.
8040+
80358041
@param str Pointer to pointer where the password will be stored.
80368042
@param len Pointer to the length of the password.
80378043
@param userdata `userdata` that was passed in the `password_ctx` struct.
80388044
@return CRYPT_OK on success
80398045
*/
80408046
int (*callback)(void **str, unsigned long *len, void *userdata);
8047+
/**
8048+
Optional free function to free the allocated buffer.
8049+
8050+
At the point where the value returned by `callback()` is not required
8051+
anymore the library will free it by either calling this `free()` function
8052+
or `XFREE()` in case this `free()` function is set to `NULL`.
8053+
8054+
@param str Pointer to the buffer to be free'd.
8055+
*/
8056+
void (*free)(void *str);
80418057
/** Opaque `userdata` pointer passed when the callback is called */
80428058
void *userdata;
80438059
} password_ctx;
@@ -8049,12 +8065,17 @@ \subsection{Depadding}
80498065
the \textit{callback} pointer inside is \textit{NULL}.
80508066

80518067
The \textit{str} pointer is declared as a \textit{void} pointer, since passwords are not necessarily
8052-
always representable as a NUL-terminated C string. Therefor the user also has to provide the length of the
8068+
always representable as a NUL-terminated C string. Therefore the user also has to provide the length of the
80538069
password via \textit{len}.
80548070

80558071
In order to prevent arbitrary limitations of the length of a password, the user is responsible for the
80568072
dynamic allocation of the buffer that holds the password. The library takes ownership of said buffer
8057-
and will zeroize it and call \texttt{XFREE} on it as soon as it doesn't require it anymore.
8073+
and will zeroize it and will free it as soon as it doesn't require it anymore.
8074+
Since the user can not necessarily ensure the usage of the same dynamic memory allocation API, as used
8075+
within the library, the library provides a way to pass a custom `free()` function within the password context.
8076+
In case the \textit{free} function pointer is set, the library will use said function to free
8077+
the string \textit{str}. In case \textit{free} is NULL, the default `XFREE()` function will be used.
8078+
80588079

80598080
An example usage is as follows:
80608081

0 commit comments

Comments
 (0)