Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Wim Lewis
nettle
Commits
2fdc023b
Commit
2fdc023b
authored
Apr 26, 2014
by
Niels Möller
Browse files
Update documentation for nettle_cipher_func.
parent
7153ad93
Changes
2
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
2fdc023b
2014-04-26 Niels Möller <nisse@lysator.liu.se>
* nettle.texinfo (GCM): Document GCM_DIGEST_SIZE.
* nettle.texinfo: Update for introduction of nettle_cipher_func.
(GCM): Document GCM_DIGEST_SIZE.
(UMAC): Document new UMAC constants.
(Keyed hash functions): Make HMAC and UMAC their own info nodes.
(EAX): Document EAX.
...
...
nettle.texinfo
View file @
2fdc023b
...
...
@@ -7,14 +7,14 @@
@syncodeindex fn cp
@c
%**end of header
@set UPDATED-FOR
2.7
@set UPDATED-FOR
3.0
@set AUTHOR Niels Möller
@copying
This manual is for the Nettle library (version @value
{
UPDATED-FOR
}
), a
low-level cryptographic library.
Originally written 2001 by @value
{
AUTHOR
}
, updated 201
3
.
Originally written 2001 by @value
{
AUTHOR
}
, updated 201
4
.
@quotation
This manual is placed in the public domain. You may freely copy it, in
...
...
@@ -993,10 +993,10 @@ functions}).
@deftp
{
Meta struct
}
@code
{
struct nettle
_
hash
}
name context
_
size digest
_
size block
_
size init update digest
The last three attributes are function pointers, of types
@code
{
nettle
_
hash
_
init
_
func
}
, @code
{
nettle
_
hash
_
update
_
func
}
, and
@code
{
nettle
_
hash
_
digest
_
func
}
. The first argument to these functions is
@code
{
nettle
_
hash
_
init
_
func
*
}
, @code
{
nettle
_
hash
_
update
_
func
*
}
, and
@code
{
nettle
_
hash
_
digest
_
func
*
}
. The first argument to these functions is
@code
{
void *
}
pointer to a context struct, which is of size
@code
{
context
_
size
}
.
@code
{
context
_
size
}
.
@end deftp
@deftypevr
{
Constant Struct
}
{
struct nettle
_
hash
}
nettle
_
md2
...
...
@@ -1756,15 +1756,14 @@ Analogous to @code{twofish_encrypt}
@subsection @code
{
struct nettle
_
cipher
}
Nettle includes a struct including information about some of the more
regular cipher functions. It should be considered a little experimental,
but can be useful for applications that need a simple way to handle
various algorithms. Nettle defines these structs in
@file
{
<nettle/nettle-meta.h>
}
.
regular cipher functions. It can be useful for applications that need a
simple way to handle various algorithms. Nettle defines these structs in
@file
{
<nettle/nettle-meta.h>
}
.
@deftp
{
Meta struct
}
@code
{
struct nettle
_
cipher
}
name context
_
size block
_
size key
_
size set
_
encrypt
_
key set
_
decrypt
_
key encrypt decrypt
The last four attributes are function pointers, of types
@code
{
nettle
_
set
_
key
_
func
}
and @code
{
nettle
_
c
rypt
_
func
}
. The first
argument to these functions is a @code
{
void *
}
pointer to a context
@code
{
nettle
_
set
_
key
_
func
*
}
and @code
{
nettle
_
c
ipher
_
func
*
}
. The first
argument to these functions is a @code
{
const
void *
}
pointer to a context
struct, which is of size @code
{
context
_
size
}
.
@end deftp
...
...
@@ -1868,8 +1867,8 @@ Block Chaining (@acronym{CBC}) mode, one for encryption and one for
decryption. These functions uses @code
{
void *
}
to pass cipher contexts
around.
@deftypefun
{
void
}
cbc
_
encrypt (void *@var
{
ctx
}
, nettle
_
c
rypt
_
func @var
{
f
}
, size
_
t @var
{
block
_
size
}
, uint8
_
t *@var
{
iv
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
dst
}
, const uint8
_
t *@var
{
src
}
)
@deftypefunx
{
void
}
cbc
_
decrypt (void *@var
{
ctx
}
,
void (
*@var
{
f
}
)()
, size
_
t @var
{
block
_
size
}
, uint8
_
t *@var
{
iv
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
dst
}
, const uint8
_
t *@var
{
src
}
)
@deftypefun
{
void
}
cbc
_
encrypt (
const
void *@var
{
ctx
}
, nettle
_
c
ipher
_
func
*
@var
{
f
}
, size
_
t @var
{
block
_
size
}
, uint8
_
t *@var
{
iv
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
dst
}
, const uint8
_
t *@var
{
src
}
)
@deftypefunx
{
void
}
cbc
_
decrypt (
const
void *@var
{
ctx
}
,
nettle
_
cipher
_
func
*@var
{
f
}
, size
_
t @var
{
block
_
size
}
, uint8
_
t *@var
{
iv
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
dst
}
, const uint8
_
t *@var
{
src
}
)
Applies the encryption or decryption function @var
{
f
}
in @acronym
{
CBC
}
mode. The final ciphertext block processed is copied into @var
{
iv
}
...
...
@@ -1964,7 +1963,7 @@ similar rôle as the @acronym{IV} for @acronym{CBC}. When adding,
byte order. For the last block, @code
{
E
_
k(IC + n - 1) [1..m]
}
means that
the cipher output is truncated to @code
{
m
}
bytes.
@deftypefun
{
void
}
ctr
_
crypt (void *@var
{
ctx
}
, nettle
_
c
rypt
_
func @var
{
f
}
, size
_
t @var
{
block
_
size
}
, uint8
_
t *@var
{
ctr
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
dst
}
, const uint8
_
t *@var
{
src
}
)
@deftypefun
{
void
}
ctr
_
crypt (
const
void *@var
{
ctx
}
, nettle
_
c
ipher
_
func
*
@var
{
f
}
, size
_
t @var
{
block
_
size
}
, uint8
_
t *@var
{
ctr
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
dst
}
, const uint8
_
t *@var
{
src
}
)
Applies the encryption function @var
{
f
}
in @acronym
{
CTR
}
mode. Note that
for @acronym
{
CTR
}
mode, encryption and decryption is the same operation,
...
...
@@ -2247,7 +2246,7 @@ Size of the @acronym{GCM} digest, also 16.
Recommended size of the @acronym
{
IV
}
, 12. Other sizes are allowed.
@end defvr
@deftypefun void gcm
_
set
_
key (struct gcm
_
key *@var
{
key
}
, void *@var
{
cipher
}
, nettle
_
c
rypt
_
func *@var
{
f
}
)
@deftypefun void gcm
_
set
_
key (struct gcm
_
key *@var
{
key
}
,
const
void *@var
{
cipher
}
, nettle
_
c
ipher
_
func *@var
{
f
}
)
Initializes @var
{
key
}
. @var
{
cipher
}
gives a context struct for the
underlying cipher, which must have been previously initialized for
encryption, and @var
{
f
}
is the encryption function.
...
...
@@ -2266,15 +2265,15 @@ for each message @emph{must} use a length that is a multiple of the
block size.
@end deftypefun
@deftypefun void gcm
_
encrypt (struct gcm
_
ctx *@var
{
ctx
}
, const struct gcm
_
key *@var
{
key
}
void *@var
{
cipher
}
, nettle
_
c
rypt
_
func *@var
{
f
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
dst
}
, const uint8
_
t *@var
{
src
}
)
@deftypefunx void gcm
_
decrypt (struct gcm
_
ctx *@var
{
ctx
}
, const struct gcm
_
key *@var
{
key
}
, void *@var
{
cipher
}
, nettle
_
c
rypt
_
func *@var
{
f
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
dst
}
, const uint8
_
t *@var
{
src
}
)
@deftypefun void gcm
_
encrypt (struct gcm
_
ctx *@var
{
ctx
}
, const struct gcm
_
key *@var
{
key
}
, const
void *@var
{
cipher
}
, nettle
_
c
ipher
_
func *@var
{
f
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
dst
}
, const uint8
_
t *@var
{
src
}
)
@deftypefunx void gcm
_
decrypt (struct gcm
_
ctx *@var
{
ctx
}
, const struct gcm
_
key *@var
{
key
}
,
const
void *@var
{
cipher
}
, nettle
_
c
ipher
_
func *@var
{
f
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
dst
}
, const uint8
_
t *@var
{
src
}
)
Encrypts or decrypts the data of a message. @var
{
cipher
}
is the context
struct for the underlying cipher and @var
{
f
}
is the encryption function.
All but the last call for each message @emph
{
must
}
use a length that is
a multiple of the block size.
@end deftypefun
@deftypefun void gcm
_
digest (struct gcm
_
ctx *@var
{
ctx
}
, const struct gcm
_
key *@var
{
key
}
, void *@var
{
cipher
}
, nettle
_
c
rypt
_
func *@var
{
f
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
digest
}
)
@deftypefun void gcm
_
digest (struct gcm
_
ctx *@var
{
ctx
}
, const struct gcm
_
key *@var
{
key
}
,
const
void *@var
{
cipher
}
, nettle
_
c
ipher
_
func *@var
{
f
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
digest
}
)
Extracts the message digest (also known ``authentication tag''). This is
the final operation when processing a message. @var
{
length
}
is usually
equal to @code
{
GCM
_
DIGEST
_
SIZE
}
, but if you provide a smaller value,
...
...
@@ -2483,26 +2482,26 @@ Holds state corresponding to a particular message.
@acronym
{
CCM
}
's block size, 16.
@end defvr
@deftypefun void ccm
_
set
_
nonce (struct ccm
_
ctx *@var
{
ctx
}
, const void *@var
{
cipher
}
, nettle
_
c
rypt
_
func *@var
{
f
}
, size
_
t @var
{
noncelen
}
, const uint8
_
t *@var
{
nonce
}
, size
_
t @var
{
authlen
}
, size
_
t @var
{
msglen
}
, size
_
t @var
{
taglen
}
)
@deftypefun void ccm
_
set
_
nonce (struct ccm
_
ctx *@var
{
ctx
}
, const void *@var
{
cipher
}
, nettle
_
c
ipher
_
func *@var
{
f
}
, size
_
t @var
{
noncelen
}
, const uint8
_
t *@var
{
nonce
}
, size
_
t @var
{
authlen
}
, size
_
t @var
{
msglen
}
, size
_
t @var
{
taglen
}
)
Initializes @var
{
ctx
}
using the given nonce and the sizes of the
authenticated data, message, and @acronym
{
MAC
}
to be processed.
@end deftypefun
@deftypefun void ccm
_
update (struct ccm
_
ctx *@var
{
ctx
}
, const void *@var
{
cipher
}
, nettle
_
c
rypt
_
func *@var
{
f
}
, size
_
t @var
{
length
}
, const uint8
_
t *@var
{
data
}
)
@deftypefun void ccm
_
update (struct ccm
_
ctx *@var
{
ctx
}
, const void *@var
{
cipher
}
, nettle
_
c
ipher
_
func *@var
{
f
}
, size
_
t @var
{
length
}
, const uint8
_
t *@var
{
data
}
)
Provides associated data to be authenticated. Must be called after
@code
{
ccm
_
set
_
nonce
}
, and before @code
{
ccm
_
encrypt
}
, @code
{
ccm
_
decrypt
}
, or
@code
{
ccm
_
digest
}
.
@end deftypefun
@deftypefun void ccm
_
encrypt (struct ccm
_
ctx *@var
{
ctx
}
, const void *@var
{
cipher
}
, nettle
_
c
rypt
_
func *@var
{
f
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
dst
}
, const uint8
_
t *@var
{
src
}
)
@deftypefunx void ccm
_
decrypt (struct ccm
_
ctx *@var
{
ctx
}
, const void *@var
{
cipher
}
, nettle
_
c
rypt
_
func *@var
{
f
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
dst
}
, const uint8
_
t *@var
{
src
}
)
@deftypefun void ccm
_
encrypt (struct ccm
_
ctx *@var
{
ctx
}
, const void *@var
{
cipher
}
, nettle
_
c
ipher
_
func *@var
{
f
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
dst
}
, const uint8
_
t *@var
{
src
}
)
@deftypefunx void ccm
_
decrypt (struct ccm
_
ctx *@var
{
ctx
}
, const void *@var
{
cipher
}
, nettle
_
c
ipher
_
func *@var
{
f
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
dst
}
, const uint8
_
t *@var
{
src
}
)
Encrypts or decrypts the message data. Must be called after
@code
{
ccm
_
set
_
nonce
}
and before @code
{
ccm
_
digest
}
. All but the last call
for each message @emph
{
must
}
use a length that is a multiple of the
block size.
@end deftypefun
@deftypefun void ccm
_
digest (struct ccm
_
ctx *@var
{
ctx
}
, const void *@var
{
cipher
}
, nettle
_
c
rypt
_
func *@var
{
f
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
digest
}
)
@deftypefun void ccm
_
digest (struct ccm
_
ctx *@var
{
ctx
}
, const void *@var
{
cipher
}
, nettle
_
c
ipher
_
func *@var
{
f
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
digest
}
)
Extracts the message digest (also known ``authentication tag''). This is
the final operation when processing a message. @var
{
length
}
is usually
equal to the @var
{
taglen
}
parameter supplied to @code
{
ccm
_
set
_
nonce
}
,
...
...
@@ -2534,13 +2533,13 @@ passed to a function is always the size for the result, @var{clength}
for the encryption functions, and @var
{
mlength
}
for the decryption
functions.
@deftypefun void ccm
_
encrypt
_
message (void *@var
{
cipher
}
, nettle
_
c
rypt
_
func *@var
{
f
}
, size
_
t @var
{
nlength
}
, const uint8
_
t *@var
{
nonce
}
, size
_
t @var
{
alength
}
, const uint8
_
t *@var
{
adata
}
, size
_
t @var
{
tlength
}
, size
_
t @var
{
clength
}
, uint8
_
t *@var
{
dst
}
, const uint8
_
t *@var
{
src
}
)
@deftypefun void ccm
_
encrypt
_
message (void *@var
{
cipher
}
, nettle
_
c
ipher
_
func *@var
{
f
}
, size
_
t @var
{
nlength
}
, const uint8
_
t *@var
{
nonce
}
, size
_
t @var
{
alength
}
, const uint8
_
t *@var
{
adata
}
, size
_
t @var
{
tlength
}
, size
_
t @var
{
clength
}
, uint8
_
t *@var
{
dst
}
, const uint8
_
t *@var
{
src
}
)
Computes the message digest from the @var
{
adata
}
and @var
{
src
}
parameters, encrypts the plaintext from @var
{
src
}
, appends the encrypted
@acronym
{
MAC
}
to ciphertext and outputs it to @var
{
dst
}
.
@end deftypefun
@deftypefun int ccm
_
decrypt
_
message (void *@var
{
cipher
}
, nettle
_
c
rypt
_
func *@var
{
f
}
, size
_
t @var
{
nlength
}
, const uint8
_
t *@var
{
nonce
}
, size
_
t @var
{
alength
}
, const uint8
_
t *@var
{
adata
}
, size
_
t @var
{
tlength
}
, size
_
t @var
{
mlength
}
, uint8
_
t *@var
{
dst
}
, const uint8
_
t *@var
{
src
}
)
@deftypefun int ccm
_
decrypt
_
message (void *@var
{
cipher
}
, nettle
_
c
ipher
_
func *@var
{
f
}
, size
_
t @var
{
nlength
}
, const uint8
_
t *@var
{
nonce
}
, size
_
t @var
{
alength
}
, const uint8
_
t *@var
{
adata
}
, size
_
t @var
{
tlength
}
, size
_
t @var
{
mlength
}
, uint8
_
t *@var
{
dst
}
, const uint8
_
t *@var
{
src
}
)
Decrypts the ciphertext from @var
{
src
}
, outputs the plaintext to
@var
{
dst
}
, recalculates the @acronym
{
MAC
}
from @var
{
adata
}
and the
plaintext, and compares it to the final @var
{
tlength
}
bytes of
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment