e_seed.c revision 296465
1192886Sedwin/* crypto/evp/e_seed.c -*- mode:C; c-file-style: "eay" -*- */ 2192886Sedwin/* ==================================================================== 364499Swollman * Copyright (c) 2007 The OpenSSL Project. All rights reserved. 4309568Sglebius * 52742Swollman * Redistribution and use in source and binary forms, with or without 6309568Sglebius * modification, are permitted provided that the following conditions 7309568Sglebius * are met: 82742Swollman * 9309568Sglebius * 1. Redistributions of source code must retain the above copyright 10309568Sglebius * notice, this list of conditions and the following disclaimer. 11309568Sglebius * 12158421Swollman * 2. Redistributions in binary form must reproduce the above copyright 13158421Swollman * notice, this list of conditions and the following disclaimer in 14309568Sglebius * the documentation and/or other materials provided with the 152742Swollman * distribution. 1686222Swollman * 1720094Swollman * 3. All advertising materials mentioning features or use of this 1820094Swollman * software must display the following acknowledgment: 1920094Swollman * "This product includes software developed by the OpenSSL Project 20309568Sglebius * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 21309568Sglebius * 2220094Swollman * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 23267489Sedwin * endorse or promote products derived from this software without 24267489Sedwin * prior written permission. For written permission, please contact 25267489Sedwin * openssl-core@openssl.org. 26158421Swollman * 27158421Swollman * 5. Products derived from this software may not be called "OpenSSL" 2820094Swollman * nor may "OpenSSL" appear in their names without prior written 2943543Swollman * permission of the OpenSSL Project. 302742Swollman * 3143543Swollman * 6. Redistributions of any form whatsoever must retain the following 3243543Swollman * acknowledgment: 3343543Swollman * "This product includes software developed by the OpenSSL Project 3443543Swollman * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 35121098Swollman * 36267489Sedwin * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 37267489Sedwin * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 38121098Swollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 39248310Sedwin * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 40248310Sedwin * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41248310Sedwin * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 42248310Sedwin * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 43248310Sedwin * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44248310Sedwin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45309568Sglebius * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46309568Sglebius * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 47309568Sglebius * OF THE POSSIBILITY OF SUCH DAMAGE. 48309568Sglebius * ==================================================================== 49309568Sglebius * 50309568Sglebius * This product includes cryptographic software written by Eric Young 51309568Sglebius * (eay@cryptsoft.com). This product includes software written by Tim 52309568Sglebius * Hudson (tjh@cryptsoft.com). 53309568Sglebius * 54309568Sglebius */ 55273438Sdelphij 5643543Swollman#include <openssl/opensslconf.h> 57273438Sdelphij#include <openssl/evp.h> 58273438Sdelphij#include <openssl/err.h> 5943543Swollman#include <string.h> 6043543Swollman#include <assert.h> 61257682Sedwin#ifndef OPENSSL_NO_SEED 622742Swollman# include <openssl/seed.h> 6319878Swollman# include "evp_locl.h" 64114173Swollman 65114173Swollmanstatic int seed_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 66114173Swollman const unsigned char *iv, int enc); 67114173Swollman 68114173Swollmantypedef struct { 69114173Swollman SEED_KEY_SCHEDULE ks; 70114173Swollman} EVP_SEED_KEY; 71114173Swollman 72114173SwollmanIMPLEMENT_BLOCK_CIPHER(seed, ks, SEED, EVP_SEED_KEY, NID_seed, 73114173Swollman 16, 16, 16, 128, 0, seed_init_key, 0, 0, 0, 0) 74309568Sglebius 75114173Swollmanstatic int seed_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 76114173Swollman const unsigned char *iv, int enc) 77114173Swollman{ 78309568Sglebius SEED_set_key(key, ctx->cipher_data); 792742Swollman return 1; 80149514Swollman} 8114343Swollman 829908Swollman#endif 839908Swollman