lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. |
| 3 | * |
| 4 | * Licensed under the OpenSSL license (the "License"). You may not use |
| 5 | * this file except in compliance with the License. You can obtain a copy |
| 6 | * in the file LICENSE in the source distribution or at |
| 7 | * https://www.openssl.org/source/license.html |
| 8 | */ |
| 9 | |
| 10 | /* |
| 11 | * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights reserved. |
| 12 | * |
| 13 | * Redistribution and use in source and binary forms, with or without |
| 14 | * modification, are permitted provided that the following conditions |
| 15 | * are met: |
| 16 | * 1. Redistributions of source code must retain the above copyright |
| 17 | * notice, this list of conditions and the following disclaimer. |
| 18 | * 2. Neither the name of author nor the names of its contributors may |
| 19 | * be used to endorse or promote products derived from this software |
| 20 | * without specific prior written permission. |
| 21 | * |
| 22 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
| 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 25 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE |
| 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 32 | * SUCH DAMAGE. |
| 33 | */ |
| 34 | |
| 35 | #ifndef HEADER_SEED_H |
| 36 | # define HEADER_SEED_H |
| 37 | |
| 38 | # include <openssl/opensslconf.h> |
| 39 | |
| 40 | # ifndef OPENSSL_NO_SEED |
| 41 | # include <openssl/e_os2.h> |
| 42 | # include <openssl/crypto.h> |
| 43 | |
| 44 | #ifdef __cplusplus |
| 45 | extern "C" { |
| 46 | #endif |
| 47 | |
| 48 | /* look whether we need 'long' to get 32 bits */ |
| 49 | # ifdef AES_LONG |
| 50 | # ifndef SEED_LONG |
| 51 | # define SEED_LONG 1 |
| 52 | # endif |
| 53 | # endif |
| 54 | |
| 55 | # include <sys/types.h> |
| 56 | |
| 57 | # define SEED_BLOCK_SIZE 16 |
| 58 | # define SEED_KEY_LENGTH 16 |
| 59 | |
| 60 | typedef struct seed_key_st { |
| 61 | # ifdef SEED_LONG |
| 62 | unsigned long data[32]; |
| 63 | # else |
| 64 | unsigned int data[32]; |
| 65 | # endif |
| 66 | } SEED_KEY_SCHEDULE; |
| 67 | |
| 68 | void SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH], |
| 69 | SEED_KEY_SCHEDULE *ks); |
| 70 | |
| 71 | void SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE], |
| 72 | unsigned char d[SEED_BLOCK_SIZE], |
| 73 | const SEED_KEY_SCHEDULE *ks); |
| 74 | void SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE], |
| 75 | unsigned char d[SEED_BLOCK_SIZE], |
| 76 | const SEED_KEY_SCHEDULE *ks); |
| 77 | |
| 78 | void SEED_ecb_encrypt(const unsigned char *in, unsigned char *out, |
| 79 | const SEED_KEY_SCHEDULE *ks, int enc); |
| 80 | void SEED_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len, |
| 81 | const SEED_KEY_SCHEDULE *ks, |
| 82 | unsigned char ivec[SEED_BLOCK_SIZE], int enc); |
| 83 | void SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out, |
| 84 | size_t len, const SEED_KEY_SCHEDULE *ks, |
| 85 | unsigned char ivec[SEED_BLOCK_SIZE], int *num, |
| 86 | int enc); |
| 87 | void SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out, |
| 88 | size_t len, const SEED_KEY_SCHEDULE *ks, |
| 89 | unsigned char ivec[SEED_BLOCK_SIZE], int *num); |
| 90 | |
| 91 | # ifdef __cplusplus |
| 92 | } |
| 93 | # endif |
| 94 | # endif |
| 95 | |
| 96 | #endif |