• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

TLS/SSL and crypto library


Commit MetaInfo

Revisióne6738d4be8d4ef42f213921351e7e9df79be7d1a (tree)
Tiempo2004-02-03 00:25:30
AutorBen Laurie <ben@open...>
CommiterBen Laurie

Log Message

Improve test suite.

Cambiar Resumen

Diferencia incremental

--- a/fips/fips_test_suite.c
+++ b/fips/fips_test_suite.c
@@ -23,6 +23,7 @@
2323 #include <openssl/sha.h>
2424 #include <openssl/err.h>
2525 #include <openssl/fips.h>
26+#include <openssl/md5.h>
2627
2728 #ifndef OPENSSL_FIPS
2829 int main(int argc, char *argv[])
@@ -65,7 +66,8 @@ static int FIPS_des_test()
6566 DES_cblock ciphertext;
6667 DES_cblock buf;
6768
68- DES_set_key(&userkey, &key);
69+ if(DES_set_key(&userkey, &key))
70+ return 0;
6971 DES_ecb_encrypt( &plaintext, &ciphertext, &key, 1);
7072 DES_ecb_encrypt( &ciphertext, &buf, &key, 0);
7173 if (memcmp(buf, plaintext, sizeof(buf)))
@@ -86,7 +88,8 @@ static int FIPS_dsa_test()
8688 dsa = DSA_generate_parameters(512,NULL,0,NULL,NULL,NULL,NULL);
8789 if (!dsa)
8890 return 0;
89- DSA_generate_key(dsa);
91+ if(!DSA_generate_key(dsa))
92+ return 0;
9093 if ( DSA_sign(0,dgst,strlen(dgst),sig,&siglen,dsa) != 1 )
9194 return 0;
9295 if ( DSA_verify(0,dgst,strlen(dgst),sig,siglen,dsa) != 1 )
@@ -138,6 +141,24 @@ static int FIPS_sha1_test()
138141 return 1;
139142 }
140143
144+/* MD5: generate hash of known digest value and compate to known
145+ precomputed correct hash */
146+
147+static int md5_test()
148+ {
149+ unsigned char digest[MD5_DIGEST_LENGTH] =
150+ { 0x48, 0x50, 0xf0, 0xa3, 0x3a, 0xed, 0xd3, 0xaf, 0x6e, 0x47, 0x7f, 0x83, 0x02, 0xb1, 0x09, 0x68 };
151+ char str[] = "etaonrishd";
152+
153+ unsigned char md[MD5_DIGEST_LENGTH];
154+
155+ if (!MD5(str,strlen(str),md))
156+ return 0;
157+ if (memcmp(md,digest,sizeof(md)))
158+ return 0;
159+ return 1;
160+ }
161+
141162 static int Error;
142163 const char * Fail(const char *msg)
143164 {
@@ -150,6 +171,11 @@ int main(int argc,char **argv)
150171
151172 printf("\tFIPS-mode test application\n\n");
152173
174+ /* Non-Approved cryptographic operation
175+ */
176+ printf("0. Non-Approved cryptographic operation...");
177+ printf( md5_test() ? "successful\n" : Fail("FAILED!\n") );
178+
153179 /* Power-up self test failure
154180 */
155181 printf("1. Automatic power-up self test...");
@@ -205,6 +231,12 @@ int main(int argc,char **argv)
205231 printf("7. SHA-1 hash...");
206232 printf( FIPS_sha1_test() ? "successful\n" : Fail("FAILED!\n") );
207233
234+ /* Non-Approved cryptographic operation
235+ */
236+ printf("8. Non-Approved cryptographic operation...");
237+ printf( md5_test() ? Fail("passed INCORRECTLY!\n")
238+ : "failed as expected\n" );
239+
208240 printf("\nAll tests completed with %d errors\n", Error);
209241 return 0;
210242 }