1295009Sjkim/* crypto/evp/e_seed.c */ 2183234Ssimon/* ==================================================================== 3183234Ssimon * Copyright (c) 2007 The OpenSSL Project. All rights reserved. 4183234Ssimon * 5183234Ssimon * Redistribution and use in source and binary forms, with or without 6183234Ssimon * modification, are permitted provided that the following conditions 7183234Ssimon * are met: 8183234Ssimon * 9183234Ssimon * 1. Redistributions of source code must retain the above copyright 10280297Sjkim * notice, this list of conditions and the following disclaimer. 11183234Ssimon * 12183234Ssimon * 2. Redistributions in binary form must reproduce the above copyright 13183234Ssimon * notice, this list of conditions and the following disclaimer in 14183234Ssimon * the documentation and/or other materials provided with the 15183234Ssimon * distribution. 16183234Ssimon * 17183234Ssimon * 3. All advertising materials mentioning features or use of this 18183234Ssimon * software must display the following acknowledgment: 19183234Ssimon * "This product includes software developed by the OpenSSL Project 20183234Ssimon * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 21183234Ssimon * 22183234Ssimon * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 23183234Ssimon * endorse or promote products derived from this software without 24183234Ssimon * prior written permission. For written permission, please contact 25183234Ssimon * openssl-core@openssl.org. 26183234Ssimon * 27183234Ssimon * 5. Products derived from this software may not be called "OpenSSL" 28183234Ssimon * nor may "OpenSSL" appear in their names without prior written 29183234Ssimon * permission of the OpenSSL Project. 30183234Ssimon * 31183234Ssimon * 6. Redistributions of any form whatsoever must retain the following 32183234Ssimon * acknowledgment: 33183234Ssimon * "This product includes software developed by the OpenSSL Project 34183234Ssimon * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 35183234Ssimon * 36183234Ssimon * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 37183234Ssimon * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 38183234Ssimon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 39183234Ssimon * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 40183234Ssimon * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41183234Ssimon * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 42183234Ssimon * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 43183234Ssimon * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44183234Ssimon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45183234Ssimon * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46183234Ssimon * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 47183234Ssimon * OF THE POSSIBILITY OF SUCH DAMAGE. 48183234Ssimon * ==================================================================== 49183234Ssimon * 50183234Ssimon * This product includes cryptographic software written by Eric Young 51183234Ssimon * (eay@cryptsoft.com). This product includes software written by Tim 52183234Ssimon * Hudson (tjh@cryptsoft.com). 53183234Ssimon * 54183234Ssimon */ 55183234Ssimon 56183234Ssimon#include <openssl/opensslconf.h> 57238405Sjkim#ifndef OPENSSL_NO_SEED 58280297Sjkim# include <openssl/evp.h> 59280297Sjkim# include <openssl/err.h> 60280297Sjkim# include <string.h> 61280297Sjkim# include <assert.h> 62280297Sjkim# include <openssl/seed.h> 63280297Sjkim# include "evp_locl.h" 64183234Ssimon 65280297Sjkimstatic int seed_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 66280297Sjkim const unsigned char *iv, int enc); 67183234Ssimon 68280297Sjkimtypedef struct { 69280297Sjkim SEED_KEY_SCHEDULE ks; 70280297Sjkim} EVP_SEED_KEY; 71183234Ssimon 72183234SsimonIMPLEMENT_BLOCK_CIPHER(seed, ks, SEED, EVP_SEED_KEY, NID_seed, 73306195Sjkim 16, 16, 16, 128, EVP_CIPH_FLAG_DEFAULT_ASN1, 74306195Sjkim seed_init_key, 0, 0, 0, 0) 75183234Ssimon 76183234Ssimonstatic int seed_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 77183234Ssimon const unsigned char *iv, int enc) 78280297Sjkim{ 79280297Sjkim SEED_set_key(key, ctx->cipher_data); 80280297Sjkim return 1; 81280297Sjkim} 82183234Ssimon 83183234Ssimon#endif 84