aboutsummaryrefslogtreecommitdiff
path: root/test/bio_enc_test.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-08-22 16:11:55 +0100
committerMatt Caswell <matt@openssl.org>2016-08-23 09:24:29 +0100
commit61884b8140893cb75c62f7303df67291ada360fe (patch)
tree109dc8e36b969c5edcb43b3cf673298aa3f0d5be /test/bio_enc_test.c
parent8b7c51a0e4a03895a657cf2eb8d5c2aa1ca3586f (diff)
downloadopenssl-61884b8140893cb75c62f7303df67291ada360fe.zip
openssl-61884b8140893cb75c62f7303df67291ada360fe.tar.gz
openssl-61884b8140893cb75c62f7303df67291ada360fe.tar.bz2
Fix bio_enc_test
There was a block of code at the start that used the Camellia cipher. The original idea behind this was to fill the buffer with non-zero data so that oversteps can be detected. However this block failed when using no-camellia. This has been replaced with a RAND_bytes() call. I also updated the the CTR test section, since it seems to be using a CBC cipher instead of a CTR cipher. Reviewed-by: Andy Polyakov <appro@openssl.org>
Diffstat (limited to 'test/bio_enc_test.c')
-rw-r--r--test/bio_enc_test.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/test/bio_enc_test.c b/test/bio_enc_test.c
index ce55318..fad1a19 100644
--- a/test/bio_enc_test.c
+++ b/test/bio_enc_test.c
@@ -10,6 +10,7 @@
#include <string.h>
#include <openssl/evp.h>
#include <openssl/bio.h>
+#include <openssl/rand.h>
int main()
{
@@ -19,12 +20,9 @@ int main()
unsigned char out[1024], ref[1024];
int i, lref, len;
- b = BIO_new(BIO_f_cipher());
- if (!BIO_set_cipher(b, EVP_camellia_128_ctr(), key, NULL, 0))
+ /* Fill buffer with non-zero data so that over steps can be detected */
+ if (RAND_bytes(inp, sizeof(inp)) <= 0)
return -1;
- BIO_push(b, BIO_new_mem_buf(inp, sizeof(inp)));
- lref = BIO_read(b, inp, sizeof(inp));
- BIO_free_all(b);
/*
* Exercise CBC cipher
@@ -87,7 +85,7 @@ int main()
/* reference output for single-chunk operation */
b = BIO_new(BIO_f_cipher());
- if (!BIO_set_cipher(b, EVP_aes_128_cbc(), key, NULL, 0))
+ if (!BIO_set_cipher(b, EVP_aes_128_ctr(), key, NULL, 0))
return -1;
BIO_push(b, BIO_new_mem_buf(inp, sizeof(inp)));
lref = BIO_read(b, ref, sizeof(ref));
@@ -96,7 +94,7 @@ int main()
/* perform split operations and compare to reference */
for (i = 1; i < lref; i++) {
b = BIO_new(BIO_f_cipher());
- if (!BIO_set_cipher(b, EVP_aes_128_cbc(), key, NULL, 0))
+ if (!BIO_set_cipher(b, EVP_aes_128_ctr(), key, NULL, 0))
return -1;
BIO_push(b, BIO_new_mem_buf(inp, sizeof(inp)));
memset(out, 0, sizeof(out));
@@ -121,7 +119,7 @@ int main()
int delta;
b = BIO_new(BIO_f_cipher());
- if (!BIO_set_cipher(b, EVP_aes_128_cbc(), key, NULL, 0))
+ if (!BIO_set_cipher(b, EVP_aes_128_ctr(), key, NULL, 0))
return -1;
BIO_push(b, BIO_new_mem_buf(inp, sizeof(inp)));
memset(out, 0, sizeof(out));