aes_ctr.c revision 302408
191094Sdes/* crypto/aes/aes_ctr.c */
2115619Sdes/* ====================================================================
3228690Sdes * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.
491094Sdes *
591094Sdes * Redistribution and use in source and binary forms, with or without
691094Sdes * modification, are permitted provided that the following conditions
799158Sdes * are met:
899158Sdes *
999158Sdes * 1. Redistributions of source code must retain the above copyright
1091094Sdes *    notice, this list of conditions and the following disclaimer.
1191094Sdes *
1291094Sdes * 2. Redistributions in binary form must reproduce the above copyright
1391094Sdes *    notice, this list of conditions and the following disclaimer in
1491094Sdes *    the documentation and/or other materials provided with the
1591094Sdes *    distribution.
1691094Sdes *
1791094Sdes * 3. All advertising materials mentioning features or use of this
1891094Sdes *    software must display the following acknowledgment:
1991094Sdes *    "This product includes software developed by the OpenSSL Project
2091094Sdes *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
2191094Sdes *
2291094Sdes * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
2391094Sdes *    endorse or promote products derived from this software without
2491094Sdes *    prior written permission. For written permission, please contact
2591094Sdes *    openssl-core@openssl.org.
2691094Sdes *
2791094Sdes * 5. Products derived from this software may not be called "OpenSSL"
2891094Sdes *    nor may "OpenSSL" appear in their names without prior written
2991094Sdes *    permission of the OpenSSL Project.
3091094Sdes *
3191094Sdes * 6. Redistributions of any form whatsoever must retain the following
3291094Sdes *    acknowledgment:
3391094Sdes *    "This product includes software developed by the OpenSSL Project
3491094Sdes *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35255376Sdes *
3691094Sdes * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
3791094Sdes * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38228690Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39228690Sdes * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
40228690Sdes * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41228690Sdes * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
4291094Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
4391094Sdes * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4491094Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
4591094Sdes * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
4691094Sdes * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
4791094Sdes * OF THE POSSIBILITY OF SUCH DAMAGE.
4891094Sdes * ====================================================================
49115619Sdes *
50115619Sdes */
5191094Sdes
5291094Sdes#include <openssl/aes.h>
5391094Sdes#include <openssl/modes.h>
5491094Sdes
5591094Sdesvoid AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
5691094Sdes                        size_t length, const AES_KEY *key,
5791094Sdes                        unsigned char ivec[AES_BLOCK_SIZE],
58174832Sdes                        unsigned char ecount_buf[AES_BLOCK_SIZE],
5991094Sdes                        unsigned int *num)
6091094Sdes{
6191094Sdes    CRYPTO_ctr128_encrypt(in, out, length, key, ivec, ecount_buf, num,
6291094Sdes                          (block128_f) AES_encrypt);
6391094Sdes}
6491094Sdes