|  | @@ -25,11 +25,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
		
	
		
			
			| 25 | 25 |  
 | 
		
	
		
			
			| 26 | 26 |  /** @file
 | 
		
	
		
			
			| 27 | 27 |   *
 | 
		
	
		
			
			| 28 |  | - * SHA-512 tests
 | 
		
	
		
			
			|  | 28 | + * SHA-512 family tests
 | 
		
	
		
			
			| 29 | 29 |   *
 | 
		
	
		
			
			| 30 | 30 |   * NIST test vectors are taken from
 | 
		
	
		
			
			| 31 | 31 |   *
 | 
		
	
		
			
			| 32 | 32 |   *  http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA512.pdf
 | 
		
	
		
			
			|  | 33 | + *  http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA384.pdf
 | 
		
	
		
			
			| 33 | 34 |   *
 | 
		
	
		
			
			| 34 | 35 |   */
 | 
		
	
		
			
			| 35 | 36 |  
 | 
		
	
	
		
			
			|  | @@ -73,8 +74,35 @@ DIGEST_TEST ( sha512_nist_abc_stu, &sha512_algorithm, DIGEST_NIST_ABC_STU,
 | 
		
	
		
			
			| 73 | 74 |  		       0x26, 0x54, 0x5e, 0x96, 0xe5, 0x5b, 0x87, 0x4b, 0xe9,
 | 
		
	
		
			
			| 74 | 75 |  		       0x09 ) );
 | 
		
	
		
			
			| 75 | 76 |  
 | 
		
	
		
			
			|  | 77 | +/* Empty test vector (digest obtained from "sha384sum /dev/null") */
 | 
		
	
		
			
			|  | 78 | +DIGEST_TEST ( sha384_empty, &sha384_algorithm, DIGEST_EMPTY,
 | 
		
	
		
			
			|  | 79 | +	      DIGEST ( 0x38, 0xb0, 0x60, 0xa7, 0x51, 0xac, 0x96, 0x38, 0x4c,
 | 
		
	
		
			
			|  | 80 | +		       0xd9, 0x32, 0x7e, 0xb1, 0xb1, 0xe3, 0x6a, 0x21, 0xfd,
 | 
		
	
		
			
			|  | 81 | +		       0xb7, 0x11, 0x14, 0xbe, 0x07, 0x43, 0x4c, 0x0c, 0xc7,
 | 
		
	
		
			
			|  | 82 | +		       0xbf, 0x63, 0xf6, 0xe1, 0xda, 0x27, 0x4e, 0xde, 0xbf,
 | 
		
	
		
			
			|  | 83 | +		       0xe7, 0x6f, 0x65, 0xfb, 0xd5, 0x1a, 0xd2, 0xf1, 0x48,
 | 
		
	
		
			
			|  | 84 | +		       0x98, 0xb9, 0x5b ) );
 | 
		
	
		
			
			|  | 85 | +
 | 
		
	
		
			
			|  | 86 | +/* NIST test vector "abc" */
 | 
		
	
		
			
			|  | 87 | +DIGEST_TEST ( sha384_nist_abc, &sha384_algorithm, DIGEST_NIST_ABC,
 | 
		
	
		
			
			|  | 88 | +	      DIGEST ( 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b, 0xb5,
 | 
		
	
		
			
			|  | 89 | +		       0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07, 0x27, 0x2c,
 | 
		
	
		
			
			|  | 90 | +		       0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63, 0x1a, 0x8b, 0x60,
 | 
		
	
		
			
			|  | 91 | +		       0x5a, 0x43, 0xff, 0x5b, 0xed, 0x80, 0x86, 0x07, 0x2b,
 | 
		
	
		
			
			|  | 92 | +		       0xa1, 0xe7, 0xcc, 0x23, 0x58, 0xba, 0xec, 0xa1, 0x34,
 | 
		
	
		
			
			|  | 93 | +		       0xc8, 0x25, 0xa7 ) );
 | 
		
	
		
			
			|  | 94 | +
 | 
		
	
		
			
			|  | 95 | +/* NIST test vector "abc...stu" */
 | 
		
	
		
			
			|  | 96 | +DIGEST_TEST ( sha384_nist_abc_stu, &sha384_algorithm, DIGEST_NIST_ABC_STU,
 | 
		
	
		
			
			|  | 97 | +	      DIGEST ( 0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8, 0x3d,
 | 
		
	
		
			
			|  | 98 | +		       0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47, 0x53, 0x11,
 | 
		
	
		
			
			|  | 99 | +		       0x1b, 0x17, 0x3b, 0x3b, 0x05, 0xd2, 0x2f, 0xa0, 0x80,
 | 
		
	
		
			
			|  | 100 | +		       0x86, 0xe3, 0xb0, 0xf7, 0x12, 0xfc, 0xc7, 0xc7, 0x1a,
 | 
		
	
		
			
			|  | 101 | +		       0x55, 0x7e, 0x2d, 0xb9, 0x66, 0xc3, 0xe9, 0xfa, 0x91,
 | 
		
	
		
			
			|  | 102 | +		       0x74, 0x60, 0x39 ) );
 | 
		
	
		
			
			|  | 103 | +
 | 
		
	
		
			
			| 76 | 104 |  /**
 | 
		
	
		
			
			| 77 |  | - * Perform SHA-512 self-test
 | 
		
	
		
			
			|  | 105 | + * Perform SHA-512 family self-test
 | 
		
	
		
			
			| 78 | 106 |   *
 | 
		
	
		
			
			| 79 | 107 |   */
 | 
		
	
		
			
			| 80 | 108 |  static void sha512_test_exec ( void ) {
 | 
		
	
	
		
			
			|  | @@ -83,13 +111,18 @@ static void sha512_test_exec ( void ) {
 | 
		
	
		
			
			| 83 | 111 |  	digest_ok ( &sha512_empty );
 | 
		
	
		
			
			| 84 | 112 |  	digest_ok ( &sha512_nist_abc );
 | 
		
	
		
			
			| 85 | 113 |  	digest_ok ( &sha512_nist_abc_stu );
 | 
		
	
		
			
			|  | 114 | +	digest_ok ( &sha384_empty );
 | 
		
	
		
			
			|  | 115 | +	digest_ok ( &sha384_nist_abc );
 | 
		
	
		
			
			|  | 116 | +	digest_ok ( &sha384_nist_abc_stu );
 | 
		
	
		
			
			| 86 | 117 |  
 | 
		
	
		
			
			| 87 | 118 |  	/* Speed tests */
 | 
		
	
		
			
			| 88 | 119 |  	DBG ( "SHA512 required %ld cycles per byte\n",
 | 
		
	
		
			
			| 89 | 120 |  	      digest_cost ( &sha512_algorithm ) );
 | 
		
	
		
			
			|  | 121 | +	DBG ( "SHA384 required %ld cycles per byte\n",
 | 
		
	
		
			
			|  | 122 | +	      digest_cost ( &sha384_algorithm ) );
 | 
		
	
		
			
			| 90 | 123 |  }
 | 
		
	
		
			
			| 91 | 124 |  
 | 
		
	
		
			
			| 92 |  | -/** SHA-512 self-test */
 | 
		
	
		
			
			|  | 125 | +/** SHA-512 family self-test */
 | 
		
	
		
			
			| 93 | 126 |  struct self_test sha512_test __self_test = {
 | 
		
	
		
			
			| 94 | 127 |  	.name = "sha512",
 | 
		
	
		
			
			| 95 | 128 |  	.exec = sha512_test_exec,
 |