seed.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * 1. Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * 2. Neither the name of author nor the names of its contributors may
  10. * be used to endorse or promote products derived from this software
  11. * without specific prior written permission.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  14. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  16. * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
  17. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  18. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  19. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  20. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  21. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  22. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. * SUCH DAMAGE.
  24. *
  25. */
  26. /* ====================================================================
  27. * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved.
  28. *
  29. * Redistribution and use in source and binary forms, with or without
  30. * modification, are permitted provided that the following conditions
  31. * are met:
  32. *
  33. * 1. Redistributions of source code must retain the above copyright
  34. * notice, this list of conditions and the following disclaimer.
  35. *
  36. * 2. Redistributions in binary form must reproduce the above copyright
  37. * notice, this list of conditions and the following disclaimer in
  38. * the documentation and/or other materials provided with the
  39. * distribution.
  40. *
  41. * 3. All advertising materials mentioning features or use of this
  42. * software must display the following acknowledgment:
  43. * "This product includes software developed by the OpenSSL Project
  44. * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
  45. *
  46. * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
  47. * endorse or promote products derived from this software without
  48. * prior written permission. For written permission, please contact
  49. * [email protected].
  50. *
  51. * 5. Products derived from this software may not be called "OpenSSL"
  52. * nor may "OpenSSL" appear in their names without prior written
  53. * permission of the OpenSSL Project.
  54. *
  55. * 6. Redistributions of any form whatsoever must retain the following
  56. * acknowledgment:
  57. * "This product includes software developed by the OpenSSL Project
  58. * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
  59. *
  60. * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
  61. * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  62. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  63. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
  64. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  65. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  66. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  67. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  68. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  69. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  70. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  71. * OF THE POSSIBILITY OF SUCH DAMAGE.
  72. * ====================================================================
  73. *
  74. * This product includes cryptographic software written by Eric Young
  75. * ([email protected]). This product includes software written by Tim
  76. * Hudson ([email protected]).
  77. *
  78. */
  79. #ifndef HEADER_SEED_H
  80. # define HEADER_SEED_H
  81. # include <openssl/opensslconf.h>
  82. # include <openssl/e_os2.h>
  83. # include <openssl/crypto.h>
  84. # ifdef OPENSSL_NO_SEED
  85. # error SEED is disabled.
  86. # endif
  87. /* look whether we need 'long' to get 32 bits */
  88. # ifdef AES_LONG
  89. # ifndef SEED_LONG
  90. # define SEED_LONG 1
  91. # endif
  92. # endif
  93. # if !defined(NO_SYS_TYPES_H)
  94. # include <sys/types.h>
  95. # endif
  96. # define SEED_BLOCK_SIZE 16
  97. # define SEED_KEY_LENGTH 16
  98. #ifdef __cplusplus
  99. extern "C" {
  100. #endif
  101. typedef struct seed_key_st {
  102. # ifdef SEED_LONG
  103. unsigned long data[32];
  104. # else
  105. unsigned int data[32];
  106. # endif
  107. } SEED_KEY_SCHEDULE;
  108. # ifdef OPENSSL_FIPS
  109. void private_SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH],
  110. SEED_KEY_SCHEDULE *ks);
  111. # endif
  112. void SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH],
  113. SEED_KEY_SCHEDULE *ks);
  114. void SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE],
  115. unsigned char d[SEED_BLOCK_SIZE],
  116. const SEED_KEY_SCHEDULE *ks);
  117. void SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE],
  118. unsigned char d[SEED_BLOCK_SIZE],
  119. const SEED_KEY_SCHEDULE *ks);
  120. void SEED_ecb_encrypt(const unsigned char *in, unsigned char *out,
  121. const SEED_KEY_SCHEDULE *ks, int enc);
  122. void SEED_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len,
  123. const SEED_KEY_SCHEDULE *ks,
  124. unsigned char ivec[SEED_BLOCK_SIZE], int enc);
  125. void SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out,
  126. size_t len, const SEED_KEY_SCHEDULE *ks,
  127. unsigned char ivec[SEED_BLOCK_SIZE], int *num,
  128. int enc);
  129. void SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out,
  130. size_t len, const SEED_KEY_SCHEDULE *ks,
  131. unsigned char ivec[SEED_BLOCK_SIZE], int *num);
  132. #ifdef __cplusplus
  133. }
  134. #endif
  135. #endif /* HEADER_SEED_H */