seed.h 3.9 KB

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