Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Nick Mathewson
Tor
Commits
2328c79a
Commit
2328c79a
authored
Mar 17, 2020
by
Nick Mathewson
👁
Browse files
Add off-by-one checks for key length.
parent
8abdb394
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/test/test_crypto.c
View file @
2328c79a
...
@@ -1505,6 +1505,21 @@ test_crypto_pk_bad_size(void *arg)
...
@@ -1505,6 +1505,21 @@ test_crypto_pk_bad_size(void *arg)
pk2
=
crypto_pk_asn1_decode_private
(
buf
,
n
,
1020
);
pk2
=
crypto_pk_asn1_decode_private
(
buf
,
n
,
1020
);
tt_assert
(
!
pk2
);
tt_assert
(
!
pk2
);
/* Set the max bit count one bit smaller: we should refuse to decode the
key.*/
pk2
=
crypto_pk_asn1_decode_private
(
buf
,
n
,
1023
);
tt_assert
(
!
pk2
);
/* Correct size: should work. */
pk2
=
crypto_pk_asn1_decode_private
(
buf
,
n
,
1024
);
tt_assert
(
pk2
);
crypto_pk_free
(
pk2
);
/* One bit larger: should work. */
pk2
=
crypto_pk_asn1_decode_private
(
buf
,
n
,
1025
);
tt_assert
(
pk2
);
crypto_pk_free
(
pk2
);
/* Set the max bit count larger: it should decode fine. */
/* Set the max bit count larger: it should decode fine. */
pk2
=
crypto_pk_asn1_decode_private
(
buf
,
n
,
2048
);
pk2
=
crypto_pk_asn1_decode_private
(
buf
,
n
,
2048
);
tt_assert
(
pk2
);
tt_assert
(
pk2
);
...
...
Write
Preview
Supports
Markdown
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