Skip to content
GitLab
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
ad5d6dc3
Commit
ad5d6dc3
authored
Oct 09, 2001
by
Niels Möller
Browse files
(yarrow256_init): Initialize the sources.
(yarrow256_random): Fixed loop condition. Rev: src/nettle/yarrow256.c:1.7
parent
2178bae2
Changes
1
Hide whitespace changes
Inline
Side-by-side
yarrow256.c
View file @
ad5d6dc3
...
...
@@ -50,16 +50,46 @@
void
yarrow256_init
(
struct
yarrow256_ctx
*
ctx
,
int
n
,
unsigned
n
,
struct
yarrow_source
*
s
)
{
sha256_init
(
&
ctx
->
pools
[
0
]);
sha256_init
(
&
ctx
->
pools
[
1
]);
unsigned
i
;
ctx
->
seeded
=
0
;
ctx
->
nsources
=
n
;
ctx
->
sources
=
s
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
ctx
->
sources
[
i
].
estimate
[
YARROW_FAST
]
=
0
;
ctx
->
sources
[
i
].
estimate
[
YARROW_SLOW
]
=
0
;
ctx
->
sources
[
i
].
next
=
YARROW_FAST
;
}
}
static
void
yarrow_generate_block
(
struct
yarrow256_ctx
*
ctx
,
uint8_t
*
block
)
{
unsigned
i
;
aes_encrypt
(
&
ctx
->
key
,
sizeof
(
ctx
->
counter
),
block
,
ctx
->
counter
);
/* Increment counter, treating it as a big-endian number. This is
* machine independent, and follows appendix B of the NIST
* specification of cipher modes of operation.
*
* We could keep a representation of thy counter as 4 32-bit values,
* and write entire words (in big-endian byteorder) into the counter
* block, whenever they change. */
for
(
i
=
sizeof
(
ctx
->
counter
);
i
--
;
)
{
if
(
++
ctx
->
counter
[
i
])
break
;
}
}
/* NOTE: The SHA-256 digest size equals the AES key size, so we need
...
...
@@ -193,28 +223,6 @@ yarrow256_update(struct yarrow256_ctx *ctx,
}
}
static
void
yarrow_generate_block
(
struct
yarrow256_ctx
*
ctx
,
uint8_t
*
block
)
{
unsigned
i
;
aes_encrypt
(
&
ctx
->
key
,
sizeof
(
ctx
->
counter
),
block
,
ctx
->
counter
);
/* Increment counter, treating it as a big-endian number. This is
* machine independent, and follows appendix B of the NIST
* specification of cipher modes of operation.
*
* We could keep a representation of thy counter as 4 32-bit values,
* and write entire words (in big-endian byteorder) into the counter
* block, whenever they change. */
for
(
i
=
sizeof
(
ctx
->
counter
);
i
--
;
)
{
if
(
++
ctx
->
counter
[
i
])
break
;
}
}
static
void
yarrow_gate
(
struct
yarrow256_ctx
*
ctx
)
{
...
...
@@ -232,7 +240,7 @@ yarrow256_random(struct yarrow256_ctx *ctx, unsigned length, uint8_t *dst)
{
assert
(
ctx
->
seeded
);
while
(
length
>
AES_BLOCK_SIZE
)
while
(
length
>
=
AES_BLOCK_SIZE
)
{
yarrow_generate_block
(
ctx
,
dst
);
dst
+=
AES_BLOCK_SIZE
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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