Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Wim Lewis
nettle
Commits
d22bac82
Commit
d22bac82
authored
Apr 25, 2014
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename *_DATA_SIZE to *_BLOCK_SIZE.
parent
1e79b722
Changes
30
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
127 additions
and
98 deletions
+127
-98
ChangeLog
ChangeLog
+4
-0
examples/nettle-benchmark.c
examples/nettle-benchmark.c
+5
-5
gosthash94.c
gosthash94.c
+4
-4
gosthash94.h
gosthash94.h
+4
-2
md2.c
md2.c
+7
-7
md2.h
md2.h
+6
-4
md4.h
md4.h
+4
-2
md5.c
md5.c
+1
-1
md5.h
md5.h
+4
-2
nettle-meta.h
nettle-meta.h
+1
-1
nettle.texinfo
nettle.texinfo
+18
-18
ripemd160.h
ripemd160.h
+4
-2
sha1.c
sha1.c
+1
-1
sha1.h
sha1.h
+4
-2
sha2.h
sha2.h
+14
-8
sha256.c
sha256.c
+1
-1
sha3-224.c
sha3-224.c
+2
-2
sha3-256.c
sha3-256.c
+2
-2
sha3-384.c
sha3-384.c
+2
-2
sha3-512.c
sha3-512.c
+2
-2
sha3.h
sha3.h
+13
-8
sha512-224-meta.c
sha512-224-meta.c
+1
-1
sha512-256-meta.c
sha512-256-meta.c
+1
-1
sha512.c
sha512.c
+2
-2
umac-set-key.c
umac-set-key.c
+1
-1
umac.h
umac.h
+5
-3
umac128.c
umac128.c
+5
-5
umac32.c
umac32.c
+2
-2
umac64.c
umac64.c
+3
-3
umac96.c
umac96.c
+4
-4
No files found.
ChangeLog
View file @
d22bac82
2014-04-25 Niels Möller <nisse@lysator.liu.se>
2014-04-25 Niels Möller <nisse@lysator.liu.se>
* All hash-related files: Renamed all _DATA_SIZE constants to
_BLOCK_SIZE, for consistency. Old names kept for backwards
compatibility.
* nettle.texinfo (CCM): Documentation for CCM mode, contributed by
* nettle.texinfo (CCM): Documentation for CCM mode, contributed by
Owen Kirby.
Owen Kirby.
...
...
examples/nettle-benchmark.c
View file @
d22bac82
...
@@ -410,7 +410,7 @@ time_umac(void)
...
@@ -410,7 +410,7 @@ time_umac(void)
info
.
update
=
(
nettle_hash_update_func
*
)
umac32_update
;
info
.
update
=
(
nettle_hash_update_func
*
)
umac32_update
;
info
.
data
=
data
;
info
.
data
=
data
;
display
(
"umac32"
,
"update"
,
UMAC_
DATA
_SIZE
,
display
(
"umac32"
,
"update"
,
UMAC_
BLOCK
_SIZE
,
time_function
(
bench_hash
,
&
info
));
time_function
(
bench_hash
,
&
info
));
umac64_set_key
(
&
ctx64
,
key
);
umac64_set_key
(
&
ctx64
,
key
);
...
@@ -418,7 +418,7 @@ time_umac(void)
...
@@ -418,7 +418,7 @@ time_umac(void)
info
.
update
=
(
nettle_hash_update_func
*
)
umac64_update
;
info
.
update
=
(
nettle_hash_update_func
*
)
umac64_update
;
info
.
data
=
data
;
info
.
data
=
data
;
display
(
"umac64"
,
"update"
,
UMAC_
DATA
_SIZE
,
display
(
"umac64"
,
"update"
,
UMAC_
BLOCK
_SIZE
,
time_function
(
bench_hash
,
&
info
));
time_function
(
bench_hash
,
&
info
));
umac96_set_key
(
&
ctx96
,
key
);
umac96_set_key
(
&
ctx96
,
key
);
...
@@ -426,7 +426,7 @@ time_umac(void)
...
@@ -426,7 +426,7 @@ time_umac(void)
info
.
update
=
(
nettle_hash_update_func
*
)
umac96_update
;
info
.
update
=
(
nettle_hash_update_func
*
)
umac96_update
;
info
.
data
=
data
;
info
.
data
=
data
;
display
(
"umac96"
,
"update"
,
UMAC_
DATA
_SIZE
,
display
(
"umac96"
,
"update"
,
UMAC_
BLOCK
_SIZE
,
time_function
(
bench_hash
,
&
info
));
time_function
(
bench_hash
,
&
info
));
umac128_set_key
(
&
ctx128
,
key
);
umac128_set_key
(
&
ctx128
,
key
);
...
@@ -434,7 +434,7 @@ time_umac(void)
...
@@ -434,7 +434,7 @@ time_umac(void)
info
.
update
=
(
nettle_hash_update_func
*
)
umac128_update
;
info
.
update
=
(
nettle_hash_update_func
*
)
umac128_update
;
info
.
data
=
data
;
info
.
data
=
data
;
display
(
"umac128"
,
"update"
,
UMAC_
DATA
_SIZE
,
display
(
"umac128"
,
"update"
,
UMAC_
BLOCK
_SIZE
,
time_function
(
bench_hash
,
&
info
));
time_function
(
bench_hash
,
&
info
));
}
}
...
@@ -677,7 +677,7 @@ static void
...
@@ -677,7 +677,7 @@ static void
bench_sha1_compress
(
void
)
bench_sha1_compress
(
void
)
{
{
uint32_t
state
[
_SHA1_DIGEST_LENGTH
];
uint32_t
state
[
_SHA1_DIGEST_LENGTH
];
uint8_t
data
[
SHA1_
DATA
_SIZE
];
uint8_t
data
[
SHA1_
BLOCK
_SIZE
];
double
t
;
double
t
;
TIME_CYCLES
(
t
,
_nettle_sha1_compress
(
state
,
data
));
TIME_CYCLES
(
t
,
_nettle_sha1_compress
(
state
,
data
));
...
...
gosthash94.c
View file @
d22bac82
...
@@ -533,7 +533,7 @@ gosthash94_update (struct gosthash94_ctx *ctx,
...
@@ -533,7 +533,7 @@ gosthash94_update (struct gosthash94_ctx *ctx,
/* fill partial block */
/* fill partial block */
if
(
index
)
if
(
index
)
{
{
unsigned
left
=
GOSTHASH94_
DATA
_SIZE
-
index
;
unsigned
left
=
GOSTHASH94_
BLOCK
_SIZE
-
index
;
memcpy
(
ctx
->
message
+
index
,
msg
,
(
length
<
left
?
length
:
left
));
memcpy
(
ctx
->
message
+
index
,
msg
,
(
length
<
left
?
length
:
left
));
if
(
length
<
left
)
if
(
length
<
left
)
return
;
return
;
...
@@ -543,11 +543,11 @@ gosthash94_update (struct gosthash94_ctx *ctx,
...
@@ -543,11 +543,11 @@ gosthash94_update (struct gosthash94_ctx *ctx,
msg
+=
left
;
msg
+=
left
;
length
-=
left
;
length
-=
left
;
}
}
while
(
length
>=
GOSTHASH94_
DATA
_SIZE
)
while
(
length
>=
GOSTHASH94_
BLOCK
_SIZE
)
{
{
gost_compute_sum_and_hash
(
ctx
,
msg
);
gost_compute_sum_and_hash
(
ctx
,
msg
);
msg
+=
GOSTHASH94_
DATA
_SIZE
;
msg
+=
GOSTHASH94_
BLOCK
_SIZE
;
length
-=
GOSTHASH94_
DATA
_SIZE
;
length
-=
GOSTHASH94_
BLOCK
_SIZE
;
}
}
if
(
length
)
if
(
length
)
{
{
...
...
gosthash94.h
View file @
d22bac82
...
@@ -72,14 +72,16 @@ extern "C" {
...
@@ -72,14 +72,16 @@ extern "C" {
#define gosthash94_update nettle_gosthash94_update
#define gosthash94_update nettle_gosthash94_update
#define gosthash94_digest nettle_gosthash94_digest
#define gosthash94_digest nettle_gosthash94_digest
#define GOSTHASH94_
DATA
_SIZE 32
#define GOSTHASH94_
BLOCK
_SIZE 32
#define GOSTHASH94_DIGEST_SIZE 32
#define GOSTHASH94_DIGEST_SIZE 32
/* For backwards compatibility */
#define GOSTHASH94_DATA_SIZE GOSTHASH94_BLOCK_SIZE
struct
gosthash94_ctx
struct
gosthash94_ctx
{
{
uint32_t
hash
[
8
];
/* algorithm 256-bit state */
uint32_t
hash
[
8
];
/* algorithm 256-bit state */
uint32_t
sum
[
8
];
/* sum of processed message blocks */
uint32_t
sum
[
8
];
/* sum of processed message blocks */
uint8_t
message
[
GOSTHASH94_
DATA
_SIZE
];
/* 256-bit buffer for leftovers */
uint8_t
message
[
GOSTHASH94_
BLOCK
_SIZE
];
/* 256-bit buffer for leftovers */
uint64_t
length
;
/* number of processed bytes */
uint64_t
length
;
/* number of processed bytes */
};
};
...
...
md2.c
View file @
d22bac82
...
@@ -87,21 +87,21 @@ md2_transform(struct md2_ctx *ctx, const uint8_t *data)
...
@@ -87,21 +87,21 @@ md2_transform(struct md2_ctx *ctx, const uint8_t *data)
unsigned
i
;
unsigned
i
;
uint8_t
t
;
uint8_t
t
;
memcpy
(
ctx
->
X
+
16
,
data
,
MD2_
DATA
_SIZE
);
memcpy
(
ctx
->
X
+
16
,
data
,
MD2_
BLOCK
_SIZE
);
for
(
i
=
0
,
t
=
ctx
->
C
[
15
];
for
(
i
=
0
,
t
=
ctx
->
C
[
15
];
i
<
MD2_
DATA
_SIZE
;
i
++
)
i
<
MD2_
BLOCK
_SIZE
;
i
++
)
{
{
ctx
->
X
[
2
*
MD2_
DATA
_SIZE
+
i
]
ctx
->
X
[
2
*
MD2_
BLOCK
_SIZE
+
i
]
=
ctx
->
X
[
i
]
^
ctx
->
X
[
MD2_
DATA
_SIZE
+
i
];
=
ctx
->
X
[
i
]
^
ctx
->
X
[
MD2_
BLOCK
_SIZE
+
i
];
t
=
(
ctx
->
C
[
i
]
^=
S
[
data
[
i
]
^
t
]);
t
=
(
ctx
->
C
[
i
]
^=
S
[
data
[
i
]
^
t
]);
}
}
for
(
i
=
t
=
0
;
for
(
i
=
t
=
0
;
i
<
MD2_
DATA
_SIZE
+
2
;
i
<
MD2_
BLOCK
_SIZE
+
2
;
t
=
(
t
+
i
)
&
0xff
,
i
++
)
t
=
(
t
+
i
)
&
0xff
,
i
++
)
{
{
unsigned
j
;
unsigned
j
;
for
(
j
=
0
;
j
<
3
*
MD2_
DATA
_SIZE
;
j
++
)
for
(
j
=
0
;
j
<
3
*
MD2_
BLOCK
_SIZE
;
j
++
)
t
=
(
ctx
->
X
[
j
]
^=
S
[
t
]);
t
=
(
ctx
->
X
[
j
]
^=
S
[
t
]);
}
}
}
}
...
@@ -129,7 +129,7 @@ md2_digest(struct md2_ctx *ctx,
...
@@ -129,7 +129,7 @@ md2_digest(struct md2_ctx *ctx,
assert
(
length
<=
MD2_DIGEST_SIZE
);
assert
(
length
<=
MD2_DIGEST_SIZE
);
left
=
MD2_
DATA
_SIZE
-
ctx
->
index
;
left
=
MD2_
BLOCK
_SIZE
-
ctx
->
index
;
memset
(
ctx
->
block
+
ctx
->
index
,
left
,
left
);
memset
(
ctx
->
block
+
ctx
->
index
,
left
,
left
);
md2_transform
(
ctx
,
ctx
->
block
);
md2_transform
(
ctx
,
ctx
->
block
);
...
...
md2.h
View file @
d22bac82
...
@@ -46,13 +46,15 @@ extern "C" {
...
@@ -46,13 +46,15 @@ extern "C" {
#define md2_digest nettle_md2_digest
#define md2_digest nettle_md2_digest
#define MD2_DIGEST_SIZE 16
#define MD2_DIGEST_SIZE 16
#define MD2_DATA_SIZE 16
#define MD2_BLOCK_SIZE 16
/* For backwards compatibility */
#define MD2_DATA_SIZE MD2_BLOCK_SIZE
struct
md2_ctx
struct
md2_ctx
{
{
uint8_t
C
[
MD2_
DATA
_SIZE
];
uint8_t
C
[
MD2_
BLOCK
_SIZE
];
uint8_t
X
[
3
*
MD2_
DATA
_SIZE
];
uint8_t
X
[
3
*
MD2_
BLOCK
_SIZE
];
uint8_t
block
[
MD2_
DATA
_SIZE
];
/* Block buffer */
uint8_t
block
[
MD2_
BLOCK
_SIZE
];
/* Block buffer */
unsigned
index
;
/* Into buffer */
unsigned
index
;
/* Into buffer */
};
};
...
...
md4.h
View file @
d22bac82
...
@@ -46,7 +46,9 @@ extern "C" {
...
@@ -46,7 +46,9 @@ extern "C" {
#define md4_digest nettle_md4_digest
#define md4_digest nettle_md4_digest
#define MD4_DIGEST_SIZE 16
#define MD4_DIGEST_SIZE 16
#define MD4_DATA_SIZE 64
#define MD4_BLOCK_SIZE 64
/* For backwards compatibility */
#define MD4_DATA_SIZE MD4_BLOCK_SIZE
/* Digest is kept internally as 4 32-bit words. */
/* Digest is kept internally as 4 32-bit words. */
#define _MD4_DIGEST_LENGTH 4
#define _MD4_DIGEST_LENGTH 4
...
@@ -56,7 +58,7 @@ struct md4_ctx
...
@@ -56,7 +58,7 @@ struct md4_ctx
{
{
uint32_t
state
[
_MD4_DIGEST_LENGTH
];
uint32_t
state
[
_MD4_DIGEST_LENGTH
];
uint64_t
count
;
/* Block count */
uint64_t
count
;
/* Block count */
uint8_t
block
[
MD4_
DATA
_SIZE
];
/* Block buffer */
uint8_t
block
[
MD4_
BLOCK
_SIZE
];
/* Block buffer */
unsigned
index
;
/* Into buffer */
unsigned
index
;
/* Into buffer */
};
};
...
...
md5.c
View file @
d22bac82
...
@@ -85,7 +85,7 @@ md5_digest(struct md5_ctx *ctx,
...
@@ -85,7 +85,7 @@ md5_digest(struct md5_ctx *ctx,
/* There are 512 = 2^9 bits in one block */
/* There are 512 = 2^9 bits in one block */
bit_count
=
(
ctx
->
count
<<
9
)
|
(
ctx
->
index
<<
3
);
bit_count
=
(
ctx
->
count
<<
9
)
|
(
ctx
->
index
<<
3
);
LE_WRITE_UINT64
(
ctx
->
block
+
(
MD5_
DATA
_SIZE
-
8
),
bit_count
);
LE_WRITE_UINT64
(
ctx
->
block
+
(
MD5_
BLOCK
_SIZE
-
8
),
bit_count
);
_nettle_md5_compress
(
ctx
->
state
,
ctx
->
block
);
_nettle_md5_compress
(
ctx
->
state
,
ctx
->
block
);
_nettle_write_le32
(
length
,
digest
,
ctx
->
state
);
_nettle_write_le32
(
length
,
digest
,
ctx
->
state
);
...
...
md5.h
View file @
d22bac82
...
@@ -46,7 +46,9 @@ extern "C" {
...
@@ -46,7 +46,9 @@ extern "C" {
#define md5_digest nettle_md5_digest
#define md5_digest nettle_md5_digest
#define MD5_DIGEST_SIZE 16
#define MD5_DIGEST_SIZE 16
#define MD5_DATA_SIZE 64
#define MD5_BLOCK_SIZE 64
/* For backwards compatibility */
#define MD5_DATA_SIZE MD5_BLOCK_SIZE
/* Digest is kept internally as 4 32-bit words. */
/* Digest is kept internally as 4 32-bit words. */
#define _MD5_DIGEST_LENGTH 4
#define _MD5_DIGEST_LENGTH 4
...
@@ -55,7 +57,7 @@ struct md5_ctx
...
@@ -55,7 +57,7 @@ struct md5_ctx
{
{
uint32_t
state
[
_MD5_DIGEST_LENGTH
];
uint32_t
state
[
_MD5_DIGEST_LENGTH
];
uint64_t
count
;
/* Block count */
uint64_t
count
;
/* Block count */
uint8_t
block
[
MD5_
DATA
_SIZE
];
/* Block buffer */
uint8_t
block
[
MD5_
BLOCK
_SIZE
];
/* Block buffer */
unsigned
index
;
/* Into buffer */
unsigned
index
;
/* Into buffer */
};
};
...
...
nettle-meta.h
View file @
d22bac82
...
@@ -108,7 +108,7 @@ struct nettle_hash
...
@@ -108,7 +108,7 @@ struct nettle_hash
#name, \
#name, \
sizeof(struct name##_ctx), \
sizeof(struct name##_ctx), \
NAME##_DIGEST_SIZE, \
NAME##_DIGEST_SIZE, \
NAME##_
DATA
_SIZE, \
NAME##_
BLOCK
_SIZE, \
(nettle_hash_init_func *) name##_init, \
(nettle_hash_init_func *) name##_init, \
(nettle_hash_update_func *) name##_update, \
(nettle_hash_update_func *) name##_update, \
(nettle_hash_digest_func *) name##_digest \
(nettle_hash_digest_func *) name##_digest \
...
...
nettle.texinfo
View file @
d22bac82
...
@@ -428,7 +428,7 @@ bits, or 32 octets. Nettle defines SHA256 in @file{<nettle/sha2.h>}.
...
@@ -428,7 +428,7 @@ bits, or 32 octets. Nettle defines SHA256 in @file{<nettle/sha2.h>}.
The size of a SHA256 digest, i.e. 32.
The size of a SHA256 digest, i.e. 32.
@end defvr
@end defvr
@defvr Constant SHA256
_
DATA
_
SIZE
@defvr Constant SHA256
_
BLOCK
_
SIZE
The internal block size of SHA256. Useful for some special constructions,
The internal block size of SHA256. Useful for some special constructions,
in particular HMAC-SHA256.
in particular HMAC-SHA256.
@end defvr
@end defvr
...
@@ -469,7 +469,7 @@ compatibility).
...
@@ -469,7 +469,7 @@ compatibility).
The size of a SHA224 digest, i.e. 28.
The size of a SHA224 digest, i.e. 28.
@end defvr
@end defvr
@defvr Constant SHA224
_
DATA
_
SIZE
@defvr Constant SHA224
_
BLOCK
_
SIZE
The internal block size of SHA224. Useful for some special constructions,
The internal block size of SHA224. Useful for some special constructions,
in particular HMAC-SHA224.
in particular HMAC-SHA224.
@end defvr
@end defvr
...
@@ -508,7 +508,7 @@ octets. Nettle defines SHA512 in @file{<nettle/sha2.h>} (and in
...
@@ -508,7 +508,7 @@ octets. Nettle defines SHA512 in @file{<nettle/sha2.h>} (and in
The size of a SHA512 digest, i.e. 64.
The size of a SHA512 digest, i.e. 64.
@end defvr
@end defvr
@defvr Constant SHA512
_
DATA
_
SIZE
@defvr Constant SHA512
_
BLOCK
_
SIZE
The internal block size of SHA512, 128. Useful for some special
The internal block size of SHA512, 128. Useful for some special
constructions, in particular HMAC-SHA512.
constructions, in particular HMAC-SHA512.
@end defvr
@end defvr
...
@@ -554,10 +554,10 @@ identifiers for other purposes. So avoid doing that.
...
@@ -554,10 +554,10 @@ identifiers for other purposes. So avoid doing that.
The digest size for each variant, i.e., 28, 32, and 48, respectively.
The digest size for each variant, i.e., 28, 32, and 48, respectively.
@end defvr
@end defvr
@defvr Constant SHA512
_
224
_
DATA
_
SIZE
@defvr Constant SHA512
_
224
_
BLOCK
_
SIZE
@defvrx Constant SHA512
_
256
_
DATA
_
SIZE
@defvrx Constant SHA512
_
256
_
BLOCK
_
SIZE
@defvrx Constant SHA384
_
DATA
_
SIZE
@defvrx Constant SHA384
_
BLOCK
_
SIZE
The internal block size, same as SHA512
_
DATA
_
SIZE, i.e., 128. Useful for
The internal block size, same as SHA512
_
BLOCK
_
SIZE, i.e., 128. Useful for
some special constructions, in particular HMAC-SHA384.
some special constructions, in particular HMAC-SHA384.
@end defvr
@end defvr
...
@@ -606,7 +606,7 @@ Nettle defines SHA3-224 in @file{<nettle/sha3.h>}.
...
@@ -606,7 +606,7 @@ Nettle defines SHA3-224 in @file{<nettle/sha3.h>}.
The size of a SHA3
_
224 digest, i.e., 28.
The size of a SHA3
_
224 digest, i.e., 28.
@end defvr
@end defvr
@defvr Constant SHA3
_
224
_
DATA
_
SIZE
@defvr Constant SHA3
_
224
_
BLOCK
_
SIZE
The internal block size of SHA3
_
224.
The internal block size of SHA3
_
224.
@end defvr
@end defvr
...
@@ -641,7 +641,7 @@ Nettle defines SHA3-256 in @file{<nettle/sha3.h>}.
...
@@ -641,7 +641,7 @@ Nettle defines SHA3-256 in @file{<nettle/sha3.h>}.
The size of a SHA3
_
256 digest, i.e., 32.
The size of a SHA3
_
256 digest, i.e., 32.
@end defvr
@end defvr
@defvr Constant SHA3
_
256
_
DATA
_
SIZE
@defvr Constant SHA3
_
256
_
BLOCK
_
SIZE
The internal block size of SHA3
_
256.
The internal block size of SHA3
_
256.
@end defvr
@end defvr
...
@@ -675,7 +675,7 @@ Nettle defines SHA3-384 in @file{<nettle/sha3.h>}.
...
@@ -675,7 +675,7 @@ Nettle defines SHA3-384 in @file{<nettle/sha3.h>}.
The size of a SHA3
_
384 digest, i.e., 48.
The size of a SHA3
_
384 digest, i.e., 48.
@end defvr
@end defvr
@defvr Constant SHA3
_
384
_
DATA
_
SIZE
@defvr Constant SHA3
_
384
_
BLOCK
_
SIZE
The internal block size of SHA3
_
384.
The internal block size of SHA3
_
384.
@end defvr
@end defvr
...
@@ -709,7 +709,7 @@ Nettle defines SHA3-512 in @file{<nettle/sha3.h>}.
...
@@ -709,7 +709,7 @@ Nettle defines SHA3-512 in @file{<nettle/sha3.h>}.
The size of a SHA3
_
512 digest, i.e. 64.
The size of a SHA3
_
512 digest, i.e. 64.
@end defvr
@end defvr
@defvr Constant SHA3
_
512
_
DATA
_
SIZE
@defvr Constant SHA3
_
512
_
BLOCK
_
SIZE
The internal block size of SHA3
_
512.
The internal block size of SHA3
_
512.
@end defvr
@end defvr
...
@@ -757,7 +757,7 @@ described in @cite{RFC 1321}. It outputs message digests of 128 bits, or
...
@@ -757,7 +757,7 @@ described in @cite{RFC 1321}. It outputs message digests of 128 bits, or
The size of an MD5 digest, i.e. 16.
The size of an MD5 digest, i.e. 16.
@end defvr
@end defvr
@defvr Constant MD5
_
DATA
_
SIZE
@defvr Constant MD5
_
BLOCK
_
SIZE
The internal block size of MD5. Useful for some special constructions,
The internal block size of MD5. Useful for some special constructions,
in particular HMAC-MD5.
in particular HMAC-MD5.
@end defvr
@end defvr
...
@@ -801,7 +801,7 @@ Nettle defines MD2 in @file{<nettle/md2.h>}.
...
@@ -801,7 +801,7 @@ Nettle defines MD2 in @file{<nettle/md2.h>}.
The size of an MD2 digest, i.e. 16.
The size of an MD2 digest, i.e. 16.
@end defvr
@end defvr
@defvr Constant MD2
_
DATA
_
SIZE
@defvr Constant MD2
_
BLOCK
_
SIZE
The internal block size of MD2.
The internal block size of MD2.
@end defvr
@end defvr
...
@@ -838,7 +838,7 @@ existing applications and protocols.
...
@@ -838,7 +838,7 @@ existing applications and protocols.
The size of an MD4 digest, i.e. 16.
The size of an MD4 digest, i.e. 16.
@end defvr
@end defvr
@defvr Constant MD4
_
DATA
_
SIZE
@defvr Constant MD4
_
BLOCK
_
SIZE
The internal block size of MD4.
The internal block size of MD4.
@end defvr
@end defvr
...
@@ -875,7 +875,7 @@ RIPEMD160 in @file{nettle/ripemd160.h}.
...
@@ -875,7 +875,7 @@ RIPEMD160 in @file{nettle/ripemd160.h}.
The size of a RIPEMD160 digest, i.e. 20.
The size of a RIPEMD160 digest, i.e. 20.
@end defvr
@end defvr
@defvr Constant RIPEMD160
_
DATA
_
SIZE
@defvr Constant RIPEMD160
_
BLOCK
_
SIZE
The internal block size of RIPEMD160.
The internal block size of RIPEMD160.
@end defvr
@end defvr
...
@@ -911,7 +911,7 @@ in @file{<nettle/sha.h>}, for backwards compatibility).
...
@@ -911,7 +911,7 @@ in @file{<nettle/sha.h>}, for backwards compatibility).
The size of a SHA1 digest, i.e. 20.
The size of a SHA1 digest, i.e. 20.
@end defvr
@end defvr
@defvr Constant SHA1
_
DATA
_
SIZE
@defvr Constant SHA1
_
BLOCK
_
SIZE
The internal block size of SHA1. Useful for some special constructions,
The internal block size of SHA1. Useful for some special constructions,
in particular HMAC-SHA1.
in particular HMAC-SHA1.
@end defvr
@end defvr
...
@@ -949,7 +949,7 @@ Nettle defines GOSTHASH94 in @file{<nettle/gosthash94.h>}.
...
@@ -949,7 +949,7 @@ Nettle defines GOSTHASH94 in @file{<nettle/gosthash94.h>}.
The size of a GOSTHASH94 digest, i.e. 32.
The size of a GOSTHASH94 digest, i.e. 32.
@end defvr
@end defvr
@defvr Constant GOSTHASH94
_
DATA
_
SIZE
@defvr Constant GOSTHASH94
_
BLOCK
_
SIZE
The internal block size of GOSTHASH94, i.e., 32.
The internal block size of GOSTHASH94, i.e., 32.
@end defvr
@end defvr
...
@@ -2743,7 +2743,7 @@ The size of an UMAC96 digest, 12.
...
@@ -2743,7 +2743,7 @@ The size of an UMAC96 digest, 12.
@defvr Constant UMAC128
_
DIGEST
_
SIZE
@defvr Constant UMAC128
_
DIGEST
_
SIZE
The size of an UMAC128 digest, 16.
The size of an UMAC128 digest, 16.
@end defvr
@end defvr
@defvr Constant UMAC
_
DATA
_
SIZE
@defvr Constant UMAC
_
BLOCK
_
SIZE
The internal block size of UMAC.
The internal block size of UMAC.
@end defvr
@end defvr
...
...
ripemd160.h
View file @
d22bac82
...
@@ -48,7 +48,9 @@ extern "C" {
...
@@ -48,7 +48,9 @@ extern "C" {
/* RIPEMD160 */
/* RIPEMD160 */
#define RIPEMD160_DIGEST_SIZE 20
#define RIPEMD160_DIGEST_SIZE 20
#define RIPEMD160_DATA_SIZE 64
#define RIPEMD160_BLOCK_SIZE 64
/* For backwards compatibility */
#define RIPEMD160_DATA_SIZE RIPEMD160_BLOCK_SIZE
/* Digest is kept internally as 5 32-bit words. */
/* Digest is kept internally as 5 32-bit words. */
#define _RIPEMD160_DIGEST_LENGTH 5
#define _RIPEMD160_DIGEST_LENGTH 5
...
@@ -57,7 +59,7 @@ struct ripemd160_ctx
...
@@ -57,7 +59,7 @@ struct ripemd160_ctx
{
{
uint32_t
state
[
_RIPEMD160_DIGEST_LENGTH
];
uint32_t
state
[
_RIPEMD160_DIGEST_LENGTH
];
uint64_t
count
;
/* 64-bit block count */
uint64_t
count
;
/* 64-bit block count */
uint8_t
block
[
RIPEMD160_
DATA
_SIZE
];
uint8_t
block
[
RIPEMD160_
BLOCK
_SIZE
];
unsigned
int
index
;
unsigned
int
index
;
};
};
...
...
sha1.c
View file @
d22bac82
...
@@ -92,7 +92,7 @@ sha1_digest(struct sha1_ctx *ctx,
...
@@ -92,7 +92,7 @@ sha1_digest(struct sha1_ctx *ctx,
bit_count
=
(
ctx
->
count
<<
9
)
|
(
ctx
->
index
<<
3
);
bit_count
=
(
ctx
->
count
<<
9
)
|
(
ctx
->
index
<<
3
);
/* append the 64 bit count */
/* append the 64 bit count */
WRITE_UINT64
(
ctx
->
block
+
(
SHA1_
DATA
_SIZE
-
8
),
bit_count
);
WRITE_UINT64
(
ctx
->
block
+
(
SHA1_
BLOCK
_SIZE
-
8
),
bit_count
);
_nettle_sha1_compress
(
ctx
->
state
,
ctx
->
block
);
_nettle_sha1_compress
(
ctx
->
state
,
ctx
->
block
);
_nettle_write_be32
(
length
,
digest
,
ctx
->
state
);
_nettle_write_be32
(
length
,
digest
,
ctx
->
state
);
...
...
sha1.h
View file @
d22bac82
...
@@ -48,7 +48,9 @@ extern "C" {
...
@@ -48,7 +48,9 @@ extern "C" {
/* SHA1 */
/* SHA1 */
#define SHA1_DIGEST_SIZE 20
#define SHA1_DIGEST_SIZE 20
#define SHA1_DATA_SIZE 64
#define SHA1_BLOCK_SIZE 64
/* For backwards compatibility */
#define SHA1_DATA_SIZE SHA1_BLOCK_SIZE
/* Digest is kept internally as 5 32-bit words. */
/* Digest is kept internally as 5 32-bit words. */
#define _SHA1_DIGEST_LENGTH 5
#define _SHA1_DIGEST_LENGTH 5
...
@@ -57,7 +59,7 @@ struct sha1_ctx
...
@@ -57,7 +59,7 @@ struct sha1_ctx
{
{
uint32_t
state
[
_SHA1_DIGEST_LENGTH
];
/* State variables */
uint32_t
state
[
_SHA1_DIGEST_LENGTH
];
/* State variables */
uint64_t
count
;
/* 64-bit block count */
uint64_t
count
;
/* 64-bit block count */
uint8_t
block
[
SHA1_
DATA
_SIZE
];
/* SHA1 data buffer */
uint8_t
block
[
SHA1_
BLOCK
_SIZE
];
/* SHA1 data buffer */
unsigned
int
index
;
/* index into buffer */
unsigned
int
index
;
/* index into buffer */
};
};
...
...
sha2.h
View file @
d22bac82
...
@@ -56,10 +56,16 @@ extern "C" {
...
@@ -56,10 +56,16 @@ extern "C" {
#define sha512_256_init nettle_sha512_256_init
#define sha512_256_init nettle_sha512_256_init
#define sha512_256_digest nettle_sha512_256_digest
#define sha512_256_digest nettle_sha512_256_digest
/* For backwards compatibility */
#define SHA224_DATA_SIZE SHA256_BLOCK_SIZE
#define SHA256_DATA_SIZE SHA256_BLOCK_SIZE
#define SHA512_DATA_SIZE SHA512_BLOCK_SIZE
#define SHA384_DATA_SIZE SHA512_BLOCK_SIZE
/* SHA256 */
/* SHA256 */
#define SHA256_DIGEST_SIZE 32
#define SHA256_DIGEST_SIZE 32
#define SHA256_
DATA
_SIZE 64
#define SHA256_
BLOCK
_SIZE 64
/* Digest is kept internally as 8 32-bit words. */
/* Digest is kept internally as 8 32-bit words. */
#define _SHA256_DIGEST_LENGTH 8
#define _SHA256_DIGEST_LENGTH 8
...
@@ -68,7 +74,7 @@ struct sha256_ctx
...
@@ -68,7 +74,7 @@ struct sha256_ctx
{
{
uint32_t
state
[
_SHA256_DIGEST_LENGTH
];
/* State variables */
uint32_t
state
[
_SHA256_DIGEST_LENGTH
];
/* State variables */
uint64_t
count
;
/* 64-bit block count */
uint64_t
count
;
/* 64-bit block count */
uint8_t
block
[
SHA256_
DATA
_SIZE
];
/* SHA256 data buffer */
uint8_t
block
[
SHA256_
BLOCK
_SIZE
];
/* SHA256 data buffer */
unsigned
int
index
;
/* index into buffer */
unsigned
int
index
;
/* index into buffer */
};
};
...
@@ -95,7 +101,7 @@ _nettle_sha256_compress(uint32_t *state, const uint8_t *data, const uint32_t *k)
...
@@ -95,7 +101,7 @@ _nettle_sha256_compress(uint32_t *state, const uint8_t *data, const uint32_t *k)
/* SHA224, a truncated SHA256 with different initial state. */
/* SHA224, a truncated SHA256 with different initial state. */
#define SHA224_DIGEST_SIZE 28
#define SHA224_DIGEST_SIZE 28
#define SHA224_
DATA
_SIZE SHA256_
DATA
_SIZE
#define SHA224_
BLOCK
_SIZE SHA256_
BLOCK
_SIZE
#define sha224_ctx sha256_ctx
#define sha224_ctx sha256_ctx
void