Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame^] | 2 | * Copyright (c) 2012-2013 Qualcomm Atheros, Inc. |
| 3 | * All Rights Reserved. |
| 4 | * Qualcomm Atheros Confidential and Proprietary. |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 5 | */ |
| 6 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7 | * Qualcomm Inc, proprietary. All rights reserved. |
| 8 | * Ref File: //depot/software/projects/feature_branches/gen5_phase1/os/linux/classic/ap/apps/ssm/include/aniSsmAesKeyWrap.h $ |
| 9 | * |
| 10 | * Contains SSM-private declarations related to the AES key WRAP |
| 11 | * algorithm described in RFC 3394. |
| 12 | * |
| 13 | * Author: Arul V Raj |
| 14 | * Date: 27-February-2009 |
| 15 | * History:- |
| 16 | * Date Modified by Modification Information |
| 17 | * ------------------------------------------------------ |
| 18 | * |
| 19 | */ |
| 20 | |
| 21 | #ifndef _ANI_SSM_AES_KEY_WRAP_H_ |
| 22 | #define _ANI_SSM_AES_KEY_WRAP_H_ |
| 23 | |
| 24 | #define ANI_SSM_AES_KEY_WRAP_BLOCK_SIZE 8 // Bytes |
| 25 | #define AES_BLOCK_SIZE 16 // Bytes |
| 26 | |
| 27 | typedef union uAniU32ValAry{ |
| 28 | tANI_U32 val; |
| 29 | char ary[sizeof(tANI_U32)]; |
| 30 | } tAniU32ValAry; |
| 31 | |
| 32 | /** |
| 33 | * Implements the AES Key Wrap algorithm described in RFC 3394. |
| 34 | * If n is the number of blocks in plainText, of size |
| 35 | * ANI_SSM_AES_KEY_WRAP_BLOCK_SIZE, then the output value is (n+1) |
| 36 | * blocks. The first block is the IV from section 2.2.3 o the |
| 37 | * RFC. Note: It is the caller's responsibility to free the returned |
| 38 | * value. |
| 39 | * |
| 40 | * @param plainText the plaintext data to wrap |
| 41 | * @param len the length of the plaintext, which must be a multiple of |
| 42 | * ANI_SSM_AES_KEY_WRAP_BLOCK_SIZE. |
| 43 | * @param keyEncKey the encryption key |
| 44 | * @param keyEncKeyLen the length of keyEncKey |
| 45 | * @param cipherTextPtr is set to a newly allocated array containing |
| 46 | * the result if the operation succeeds. It is the caller's |
| 47 | * responsibility to free this. |
| 48 | * |
| 49 | * @return ANI_OK if the operation succeeds |
| 50 | */ |
| 51 | int |
| 52 | aniSsmAesKeyWrap(v_U32_t cryptHandle, tANI_U8 *plainText, tANI_U32 len, |
| 53 | tANI_U8 *keyEncKey, tANI_U32 keyEncKeyLen, |
| 54 | tANI_U8 **cipherTextPtr); |
| 55 | |
| 56 | /** |
| 57 | * Implements the AES Key Unwrap algorithm described in RFC 3394. |
| 58 | * If (n+1) is the number of blocks in cipherText, of size |
| 59 | * ANI_SSM_AES_KEY_WRAP_BLOCK_SIZE, then the output value is (n+1) |
| 60 | * blocks. The actual plaintext consists of n blocks that start at the |
| 61 | * second block. Note: It is the caller's responsibility to free the |
| 62 | * returned value. |
| 63 | * |
| 64 | * @param cipherText the cipertext data to unwrap |
| 65 | * @param len the length of the ciphertext, which must be a multiple of |
| 66 | * ANI_SSM_AES_KEY_WRAP_BLOCK_SIZE. |
| 67 | * @param keyEncKey the encryption key |
| 68 | * @param keyEncKeyLen the length of keyEncKey |
| 69 | * @param plainTextPtr is set to a newly allocated array containing |
| 70 | * the result if the operation succeeds. It is the caller's |
| 71 | * responsibility to free this. |
| 72 | * |
| 73 | * @return ANI_OK if the operation succeeds |
| 74 | */ |
| 75 | int |
| 76 | aniSsmAesKeyUnwrap(v_U32_t cryptHandle, tANI_U8 *cipherText, tANI_U32 len, |
| 77 | tANI_U8 *keyEncKey, tANI_U32 keyEncKeyLen, |
| 78 | tANI_U8 **plainTextPtr); |
| 79 | |
| 80 | |
| 81 | #endif //_ANI_SSM_AES_KEY_WRAP_H_ |
| 82 | |