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
c8e472cb
Commit
c8e472cb
authored
Apr 22, 2014
by
Niels Möller
Browse files
Document additional sha512 variants.
parent
9959f304
Changes
2
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
c8e472cb
2014-04-22 Niels Möller <nisse@lysator.liu.se>
* nettle.texinfo (Recommended hash functions): Document additional
sha512 variants.
* sha2.h (sha512_224_ctx, sha512_256_ctx): New aliases for the
sha512_ctx struct tag.
...
...
nettle.texinfo
View file @
c8e472cb
...
...
@@ -505,8 +505,8 @@ The size of a SHA512 digest, i.e. 64.
@end defvr
@defvr Constant SHA512
_
DATA
_
SIZE
The internal block size of SHA512. Useful for some special
constructions,
in particular HMAC-SHA512.
The internal block size of SHA512
, 128
. Useful for some special
constructions,
in particular HMAC-SHA512.
@end defvr
@deftypefun void sha512
_
init (struct sha512
_
ctx *@var
{
ctx
}
)
...
...
@@ -527,41 +527,59 @@ This function also resets the context in the same way as
@code
{
sha512
_
init
}
.
@end deftypefun
@subsubsection @acronym
{
SHA384
}
@subsubsection @acronym
{
SHA384
and other variants of SHA512
}
SHA384 is a variant of SHA512, with a different initial state, and with
the output truncated to 384 bits, or 48 octets. Nettle defines SHA384 in
@file
{
<nettle/sha2.h>
}
(and in @file
{
<nettle/sha.h>
}
, for backwards
compatibility).
Several variants of SHA512 have been defined, with a different initial
state, and with the output truncated to shorter length than 512 bits.
Naming is a bit confused, these algorithms are call SHA512-224,
SHA512-256 and SHA384, for output sizes of 224, 256 and 384 bits,
respectively. Nettle defines these in @file
{
<nettle/sha2.h>
}
(and in
@file
{
<nettle/sha.h>
}
, for backwards compatibility).
@deftp
{
Context struct
}
{
struct sha384
_
ctx
}
@deftp
{
Context struct
}
{
struct sha512
_
224
_
ctx
}
@deftpx
{
Context struct
}
{
struct sha512
_
256
_
ctx
}
@deftpx
{
Context struct
}
{
struct sha384
_
ctx
}
These context structs are all the same as sha512
_
ctx. They are defined as
simple preprocessor aliases, which may cause some problems if used as
identifiers for other purposes. So avoid doing that.
@end deftp
@defvr Constant SHA384
_
DIGEST
_
SIZE
The size of a SHA384 digest, i.e. 48.
@defvr Constant SHA512
_
224
_
DIGEST
_
SIZE
@defvrx Constant SHA512
_
256
_
DIGEST
_
SIZE
@defvrx Constant SHA384
_
DIGEST
_
SIZE
The digest sizes for each variant, i.e., 28, 32, and 48, respectively.
@end defvr
@defvr Constant SHA384
_
DATA
_
SIZE
The internal block size of SHA384. Useful for some special constructions,
in particular HMAC-SHA384.
@defvr Constant SHA512
_
224
_
DATA
_
SIZE
@defvrx Constant SHA512
_
256
_
DATA
_
SIZE
@defvrx Constant SHA384
_
DATA
_
SIZE
The internal block size, same as SHA512
_
DATA
_
SIZE, i.e., 128. Useful for
some special constructions, in particular HMAC-SHA384.
@end defvr
@deftypefun void sha384
_
init (struct sha384
_
ctx *@var
{
ctx
}
)
Initialize the SHA384 state.
@deftypefun void sha512
_
224
_
init (struct sha512
_
224
_
ctx *@var
{
ctx
}
)
@deftypefunx void sha512
_
256
_
init (struct sha512
_
256
_
ctx *@var
{
ctx
}
)
@deftypefunx void sha384
_
init (struct sha384
_
ctx *@var
{
ctx
}
)
Initialize the context struct.
@end deftypefun
@deftypefun void sha384
_
update (struct sha384
_
ctx *@var
{
ctx
}
, size
_
t @var
{
length
}
, const uint8
_
t *@var
{
data
}
)
Hash some more data.
@deftypefun void sha512
_
224
_
update (struct sha512
_
224
_
ctx *@var
{
ctx
}
, size
_
t @var
{
length
}
, const uint8
_
t *@var
{
data
}
)
@deftypefunx void sha512
_
256
_
update (struct sha512
_
256
_
ctx *@var
{
ctx
}
, size
_
t @var
{
length
}
, const uint8
_
t *@var
{
data
}
)
@deftypefunx void sha384
_
update (struct sha384
_
ctx *@var
{
ctx
}
, size
_
t @var
{
length
}
, const uint8
_
t *@var
{
data
}
)
Hash some more data. These are all aliases for sha512
_
update, which does
the same thing.
@end deftypefun
@deftypefun void sha384
_
digest (struct sha384
_
ctx *@var
{
ctx
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
digest
}
)
Performs final processing and extracts the message digest, writing it
to @var
{
digest
}
. @var
{
length
}
may be smaller than
@code
{
SHA384
_
DIGEST
_
SIZE
}
, in which case only the first @var
{
length
}
octets of the digest are written.
@deftypefun void sha512
_
224
_
digest (struct sha512
_
224
_
ctx *@var
{
ctx
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
digest
}
)
@deftypefunx void sha512
_
256
_
digest (struct sha512
_
256
_
ctx *@var
{
ctx
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
digest
}
)
@deftypefunx void sha384
_
digest (struct sha384
_
ctx *@var
{
ctx
}
, size
_
t @var
{
length
}
, uint8
_
t *@var
{
digest
}
)
Performs final processing and extracts the message digest, writing it to
@var
{
digest
}
. @var
{
length
}
may be smaller than the specified digest
size, in which case only the first @var
{
length
}
octets of the digest are
written.
Th
is
function also reset
s
the context in the same way as
@
co
de
{
sha384
_
init
}
.
Th
ese
function also reset the context in the same way as
the
co
rresponding init function
.
@end deftypefun
@subsubsection @acronym
{
SHA3-224
}
...
...
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