Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame^] | 2 | * Copyright (c) 2012-2013 The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 20 | */ |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame^] | 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 28 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 29 | * Qualcomm Inc, proprietary. All rights reserved. |
| 30 | * Ref File: //depot/software/projects/feature_branches/gen5_phase1/os/linux/classic/ap/apps/ssm/include/aniSsmAesKeyWrap.h $ |
| 31 | * |
| 32 | * Contains SSM-private declarations related to the AES key WRAP |
| 33 | * algorithm described in RFC 3394. |
| 34 | * |
| 35 | * Author: Arul V Raj |
| 36 | * Date: 27-February-2009 |
| 37 | * History:- |
| 38 | * Date Modified by Modification Information |
| 39 | * ------------------------------------------------------ |
| 40 | * |
| 41 | */ |
| 42 | |
| 43 | #ifndef _ANI_SSM_AES_KEY_WRAP_H_ |
| 44 | #define _ANI_SSM_AES_KEY_WRAP_H_ |
| 45 | |
| 46 | #define ANI_SSM_AES_KEY_WRAP_BLOCK_SIZE 8 // Bytes |
| 47 | #define AES_BLOCK_SIZE 16 // Bytes |
| 48 | |
| 49 | typedef union uAniU32ValAry{ |
| 50 | tANI_U32 val; |
| 51 | char ary[sizeof(tANI_U32)]; |
| 52 | } tAniU32ValAry; |
| 53 | |
| 54 | /** |
| 55 | * Implements the AES Key Wrap algorithm described in RFC 3394. |
| 56 | * If n is the number of blocks in plainText, of size |
| 57 | * ANI_SSM_AES_KEY_WRAP_BLOCK_SIZE, then the output value is (n+1) |
| 58 | * blocks. The first block is the IV from section 2.2.3 o the |
| 59 | * RFC. Note: It is the caller's responsibility to free the returned |
| 60 | * value. |
| 61 | * |
| 62 | * @param plainText the plaintext data to wrap |
| 63 | * @param len the length of the plaintext, which must be a multiple of |
| 64 | * ANI_SSM_AES_KEY_WRAP_BLOCK_SIZE. |
| 65 | * @param keyEncKey the encryption key |
| 66 | * @param keyEncKeyLen the length of keyEncKey |
| 67 | * @param cipherTextPtr is set to a newly allocated array containing |
| 68 | * the result if the operation succeeds. It is the caller's |
| 69 | * responsibility to free this. |
| 70 | * |
| 71 | * @return ANI_OK if the operation succeeds |
| 72 | */ |
| 73 | int |
| 74 | aniSsmAesKeyWrap(v_U32_t cryptHandle, tANI_U8 *plainText, tANI_U32 len, |
| 75 | tANI_U8 *keyEncKey, tANI_U32 keyEncKeyLen, |
| 76 | tANI_U8 **cipherTextPtr); |
| 77 | |
| 78 | /** |
| 79 | * Implements the AES Key Unwrap algorithm described in RFC 3394. |
| 80 | * If (n+1) is the number of blocks in cipherText, of size |
| 81 | * ANI_SSM_AES_KEY_WRAP_BLOCK_SIZE, then the output value is (n+1) |
| 82 | * blocks. The actual plaintext consists of n blocks that start at the |
| 83 | * second block. Note: It is the caller's responsibility to free the |
| 84 | * returned value. |
| 85 | * |
| 86 | * @param cipherText the cipertext data to unwrap |
| 87 | * @param len the length of the ciphertext, which must be a multiple of |
| 88 | * ANI_SSM_AES_KEY_WRAP_BLOCK_SIZE. |
| 89 | * @param keyEncKey the encryption key |
| 90 | * @param keyEncKeyLen the length of keyEncKey |
| 91 | * @param plainTextPtr is set to a newly allocated array containing |
| 92 | * the result if the operation succeeds. It is the caller's |
| 93 | * responsibility to free this. |
| 94 | * |
| 95 | * @return ANI_OK if the operation succeeds |
| 96 | */ |
| 97 | int |
| 98 | aniSsmAesKeyUnwrap(v_U32_t cryptHandle, tANI_U8 *cipherText, tANI_U32 len, |
| 99 | tANI_U8 *keyEncKey, tANI_U32 keyEncKeyLen, |
| 100 | tANI_U8 **plainTextPtr); |
| 101 | |
| 102 | |
| 103 | #endif //_ANI_SSM_AES_KEY_WRAP_H_ |
| 104 | |