| /* |
| * |
| * Copyright (c) 2011-2015 Nest Labs, Inc. |
| * All rights reserved. |
| * |
| * This document is the property of Nest. It is considered |
| * confidential and proprietary information. |
| * |
| * This document may not be reproduced or transmitted in any form, |
| * in whole or in part, without the express written permission of |
| * Nest. |
| * |
| * Description: |
| * Implementation of PolarSSL AES functions that maps calls onto OpenSSL's |
| * functions. |
| */ |
| |
| #include "aes.h" |
| |
| #include <stdio.h> |
| |
| int aes_setkey_enc( aes_context *ctx, const unsigned char *key, unsigned int keysize ) |
| { |
| AES_set_encrypt_key(key, (int)keysize, ctx); |
| return 0; |
| } |
| |
| int aes_setkey_dec( aes_context *ctx, const unsigned char *key, unsigned int keysize ) |
| { |
| AES_set_decrypt_key(key, (int)keysize, ctx); |
| return 0; |
| } |
| |
| |
| int aes_crypt_ecb( aes_context *ctx, |
| int mode, |
| const unsigned char input[16], |
| unsigned char output[16] ) |
| { |
| /* Only encryption supported (and needed) for now. |
| */ |
| if (mode != AES_ENCRYPT) |
| return -1; |
| AES_encrypt(input, output, ctx); |
| return 0; |
| } |
| |