2016-05-17 18:24:46 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved.
|
2007-04-23 23:48:59 +00:00
|
|
|
*
|
2016-05-17 18:24:46 +00:00
|
|
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
2007-04-23 23:48:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <openssl/opensslconf.h>
|
2016-03-21 12:00:41 +00:00
|
|
|
#ifdef OPENSSL_NO_SEED
|
|
|
|
NON_EMPTY_TRANSLATION_UNIT
|
|
|
|
#else
|
2015-01-22 03:40:55 +00:00
|
|
|
# include <openssl/evp.h>
|
|
|
|
# include <openssl/err.h>
|
|
|
|
# include <string.h>
|
|
|
|
# include <assert.h>
|
|
|
|
# include <openssl/seed.h>
|
2015-12-18 16:01:28 +00:00
|
|
|
# include "internal/evp_int.h"
|
2007-04-23 23:48:59 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
static int seed_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
|
|
|
const unsigned char *iv, int enc);
|
2007-04-23 23:48:59 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
typedef struct {
|
|
|
|
SEED_KEY_SCHEDULE ks;
|
|
|
|
} EVP_SEED_KEY;
|
2007-04-23 23:48:59 +00:00
|
|
|
|
|
|
|
IMPLEMENT_BLOCK_CIPHER(seed, ks, SEED, EVP_SEED_KEY, NID_seed,
|
2016-05-05 21:17:05 +00:00
|
|
|
16, 16, 16, 128, EVP_CIPH_FLAG_DEFAULT_ASN1,
|
|
|
|
seed_init_key, 0, 0, 0, 0)
|
2007-04-23 23:48:59 +00:00
|
|
|
|
|
|
|
static int seed_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
|
|
|
const unsigned char *iv, int enc)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
2015-12-18 16:01:28 +00:00
|
|
|
SEED_set_key(key, &EVP_C_DATA(EVP_SEED_KEY,ctx)->ks);
|
2015-01-22 03:40:55 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2007-04-23 23:48:59 +00:00
|
|
|
|
|
|
|
#endif
|