summaryrefslogtreecommitdiffstats
path: root/test/destest.c
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2016-05-31 23:05:48 -0400
committerRich Salz <rsalz@openssl.org>2016-06-01 09:28:53 -0400
commit6493e4801e9edbe1ad1e256d4ce9cd55c8aa2242 (patch)
tree9c9dd96141769aa39819a962baaf5ce04a37e1a7 /test/destest.c
parent1d54ef340864507c1b6e86238183ab4cbc7423aa (diff)
RT4337: Crash in DES
Salt must be two ASCII characters. Add tests to check for that, and a test to test the checks. Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'test/destest.c')
-rw-r--r--test/destest.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/test/destest.c b/test/destest.c
index 389d0c8352..877f71d3fb 100644
--- a/test/destest.c
+++ b/test/destest.c
@@ -35,8 +35,6 @@ int main(int argc, char *argv[])
#else
# include <openssl/des.h>
-# define crypt(c,s) (DES_crypt((c),(s)))
-
/* tisk tisk - the test keys don't all have odd parity :-( */
/* test data */
# define NUM_TESTS 34
@@ -660,16 +658,31 @@ int main(int argc, char *argv[])
}
printf("\n");
printf("fast crypt test ");
- str = crypt("testing", "ef");
+ str = DES_crypt("testing", "ef");
if (strcmp("efGnQx2725bI2", str) != 0) {
printf("fast crypt error, %s should be efGnQx2725bI2\n", str);
err = 1;
}
- str = crypt("bca76;23", "yA");
+ str = DES_crypt("bca76;23", "yA");
if (strcmp("yA1Rp/1hZXIJk", str) != 0) {
printf("fast crypt error, %s should be yA1Rp/1hZXIJk\n", str);
err = 1;
}
+ str = DES_crypt("testing", "y\202");
+ if (str != NULL) {
+ printf("salt error only usascii are accepted\n");
+ err = 1;
+ }
+ str = DES_crypt("testing", "\0A");
+ if (str != NULL) {
+ printf("salt error cannot contain null terminator\n");
+ err = 1;
+ }
+ str = DES_crypt("testing", "A");
+ if (str != NULL) {
+ printf("salt error must be at least 2\n");
+ err = 1;
+ }
printf("\n");
return (err);
}