OCBv3: ocb3_init taglen check
This commit is contained in:
		
							parent
							
								
									af63d0a55f
								
							
						
					
					
						commit
						f647baa778
					
				| @ -114,9 +114,14 @@ int ocb3_init(ocb3_state *ocb, int cipher, | |||||||
|       return CRYPT_INVALID_ARG; |       return CRYPT_INVALID_ARG; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    /* Make sure taglen isn't too long */ |    /* The blockcipher must have a 128-bit blocksize */ | ||||||
|    if (taglen > (unsigned long)cipher_descriptor[cipher].block_length) { |    if (cipher_descriptor[cipher].block_length != 16) { | ||||||
|       taglen = cipher_descriptor[cipher].block_length; |       return CRYPT_INVALID_ARG; | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    /* The TAGLEN may be any value up to 128 (bits) */ | ||||||
|  |    if (taglen > 16) { | ||||||
|  |       return CRYPT_INVALID_ARG; | ||||||
|    } |    } | ||||||
|    ocb->tag_len = taglen; |    ocb->tag_len = taglen; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -215,7 +215,7 @@ int ocb3_test(void) | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) { |     for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) { | ||||||
|         len = sizeof(outtag); |         len = 16; /* must be the same as the required taglen */ | ||||||
|         if ((err = ocb3_encrypt_authenticate_memory(idx, |         if ((err = ocb3_encrypt_authenticate_memory(idx, | ||||||
|                                                    key, sizeof(key), |                                                    key, sizeof(key), | ||||||
|                                                    nonce, sizeof(nonce), |                                                    nonce, sizeof(nonce), | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user