aes_ctr.c revision 302408
1164190Sjkoshy/* crypto/aes/aes_ctr.c */ 2164190Sjkoshy/* ==================================================================== 3164190Sjkoshy * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 4164190Sjkoshy * 5164190Sjkoshy * Redistribution and use in source and binary forms, with or without 6164190Sjkoshy * modification, are permitted provided that the following conditions 7164190Sjkoshy * are met: 8164190Sjkoshy * 9164190Sjkoshy * 1. Redistributions of source code must retain the above copyright 10164190Sjkoshy * notice, this list of conditions and the following disclaimer. 11164190Sjkoshy * 12164190Sjkoshy * 2. Redistributions in binary form must reproduce the above copyright 13164190Sjkoshy * notice, this list of conditions and the following disclaimer in 14164190Sjkoshy * the documentation and/or other materials provided with the 15164190Sjkoshy * distribution. 16164190Sjkoshy * 17164190Sjkoshy * 3. All advertising materials mentioning features or use of this 18164190Sjkoshy * software must display the following acknowledgment: 19164190Sjkoshy * "This product includes software developed by the OpenSSL Project 20164190Sjkoshy * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 21164190Sjkoshy * 22164190Sjkoshy * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 23164190Sjkoshy * endorse or promote products derived from this software without 24164190Sjkoshy * prior written permission. For written permission, please contact 25164190Sjkoshy * openssl-core@openssl.org. 26164190Sjkoshy * 27206622Suqs * 5. Products derived from this software may not be called "OpenSSL" 28164190Sjkoshy * nor may "OpenSSL" appear in their names without prior written 29164190Sjkoshy * permission of the OpenSSL Project. 30164190Sjkoshy * 31164190Sjkoshy * 6. Redistributions of any form whatsoever must retain the following 32164190Sjkoshy * acknowledgment: 33164190Sjkoshy * "This product includes software developed by the OpenSSL Project 34164190Sjkoshy * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 35164190Sjkoshy * 36164190Sjkoshy * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 37164190Sjkoshy * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 38164190Sjkoshy * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 39164190Sjkoshy * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 40164190Sjkoshy * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41164190Sjkoshy * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 42164190Sjkoshy * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 43164190Sjkoshy * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44164190Sjkoshy * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45164190Sjkoshy * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46164190Sjkoshy * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 47164190Sjkoshy * OF THE POSSIBILITY OF SUCH DAMAGE. 48164190Sjkoshy * ==================================================================== 49164190Sjkoshy * 50164190Sjkoshy */ 51164190Sjkoshy 52164190Sjkoshy#include <openssl/aes.h> 53164190Sjkoshy#include <openssl/modes.h> 54164190Sjkoshy 55164190Sjkoshyvoid AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, 56164190Sjkoshy size_t length, const AES_KEY *key, 57164190Sjkoshy unsigned char ivec[AES_BLOCK_SIZE], 58164190Sjkoshy unsigned char ecount_buf[AES_BLOCK_SIZE], 59164190Sjkoshy unsigned int *num) 60164190Sjkoshy{ 61164190Sjkoshy CRYPTO_ctr128_encrypt(in, out, length, key, ivec, ecount_buf, num, 62164190Sjkoshy (block128_f) AES_encrypt); 63164190Sjkoshy} 64164190Sjkoshy