summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2019-08-22 11:42:54 +1000
committerShane Lontis <shane.lontis@oracle.com>2019-08-22 11:42:54 +1000
commite1178600cc5d40b1e21c4a01d224afd2d8c7498a (patch)
tree9601f94492fbab46a72f96e0982025d7ec7ed236 /crypto
parent85d09e8848012d0dfdacf827d9d56730fa5daf16 (diff)
Add basic aria and camellia ciphers modes to default provider
The aes code has been refactored into generic and algorithn specific parts, so that most of the code can be shared. The cipher related files have been broken up into smaller parts. Add chunked variant of mode ciphers - aria uses this (many other ciphers will use this new code instead of the generic code used by aes). Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/9451)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/evp/e_aes.c2
-rw-r--r--crypto/evp/e_camellia.c29
-rw-r--r--crypto/evp/evp_enc.c42
-rw-r--r--crypto/include/internal/ciphermode_platform.h (renamed from crypto/include/internal/aes_platform.h)39
4 files changed, 80 insertions, 32 deletions
diff --git a/crypto/evp/e_aes.c b/crypto/evp/e_aes.c
index a46ac8f92f..39ed528060 100644
--- a/crypto/evp/e_aes.c
+++ b/crypto/evp/e_aes.c
@@ -20,7 +20,7 @@
#include "internal/cryptlib.h"
#include "internal/modes_int.h"
#include "internal/siv_int.h"
-#include "internal/aes_platform.h"
+#include "internal/ciphermode_platform.h"
#include "evp_locl.h"
typedef struct {
diff --git a/crypto/evp/e_camellia.c b/crypto/evp/e_camellia.c
index 9def167bfa..5e66101422 100644
--- a/crypto/evp/e_camellia.c
+++ b/crypto/evp/e_camellia.c
@@ -19,6 +19,7 @@ NON_EMPTY_TRANSLATION_UNIT
# include <openssl/camellia.h>
# include "internal/evp_int.h"
# include "internal/modes_int.h"
+# include "internal/ciphermode_platform.h"
static int camellia_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
const unsigned char *iv, int enc);
@@ -43,34 +44,6 @@ typedef struct {
* assembler support was in general requested... */
# include "sparc_arch.h"
-extern unsigned int OPENSSL_sparcv9cap_P[];
-
-# define SPARC_CMLL_CAPABLE (OPENSSL_sparcv9cap_P[1] & CFR_CAMELLIA)
-
-void cmll_t4_set_key(const unsigned char *key, int bits, CAMELLIA_KEY *ks);
-void cmll_t4_encrypt(const unsigned char *in, unsigned char *out,
- const CAMELLIA_KEY *key);
-void cmll_t4_decrypt(const unsigned char *in, unsigned char *out,
- const CAMELLIA_KEY *key);
-
-void cmll128_t4_cbc_encrypt(const unsigned char *in, unsigned char *out,
- size_t len, const CAMELLIA_KEY *key,
- unsigned char *ivec);
-void cmll128_t4_cbc_decrypt(const unsigned char *in, unsigned char *out,
- size_t len, const CAMELLIA_KEY *key,
- unsigned char *ivec);
-void cmll256_t4_cbc_encrypt(const unsigned char *in, unsigned char *out,
- size_t len, const CAMELLIA_KEY *key,
- unsigned char *ivec);
-void cmll256_t4_cbc_decrypt(const unsigned char *in, unsigned char *out,
- size_t len, const CAMELLIA_KEY *key,
- unsigned char *ivec);
-void cmll128_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out,
- size_t blocks, const CAMELLIA_KEY *key,
- unsigned char *ivec);
-void cmll256_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out,
- size_t blocks, const CAMELLIA_KEY *key,
- unsigned char *ivec);
static int cmll_t4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
const unsigned char *iv, int enc)
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c
index 51a6423c82..e67e20c7ba 100644
--- a/crypto/evp/evp_enc.c
+++ b/crypto/evp/evp_enc.c
@@ -175,6 +175,48 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
case NID_aria_256_ccm:
case NID_aria_192_ccm:
case NID_aria_128_ccm:
+ case NID_aria_256_ecb:
+ case NID_aria_192_ecb:
+ case NID_aria_128_ecb:
+ case NID_aria_256_cbc:
+ case NID_aria_192_cbc:
+ case NID_aria_128_cbc:
+ case NID_aria_256_ofb128:
+ case NID_aria_192_ofb128:
+ case NID_aria_128_ofb128:
+ case NID_aria_256_cfb128:
+ case NID_aria_192_cfb128:
+ case NID_aria_128_cfb128:
+ case NID_aria_256_cfb1:
+ case NID_aria_192_cfb1:
+ case NID_aria_128_cfb1:
+ case NID_aria_256_cfb8:
+ case NID_aria_192_cfb8:
+ case NID_aria_128_cfb8:
+ case NID_aria_256_ctr:
+ case NID_aria_192_ctr:
+ case NID_aria_128_ctr:
+ case NID_camellia_256_ecb:
+ case NID_camellia_192_ecb:
+ case NID_camellia_128_ecb:
+ case NID_camellia_256_cbc:
+ case NID_camellia_192_cbc:
+ case NID_camellia_128_cbc:
+ case NID_camellia_256_ofb128:
+ case NID_camellia_192_ofb128:
+ case NID_camellia_128_ofb128:
+ case NID_camellia_256_cfb128:
+ case NID_camellia_192_cfb128:
+ case NID_camellia_128_cfb128:
+ case NID_camellia_256_cfb1:
+ case NID_camellia_192_cfb1:
+ case NID_camellia_128_cfb1:
+ case NID_camellia_256_cfb8:
+ case NID_camellia_192_cfb8:
+ case NID_camellia_128_cfb8:
+ case NID_camellia_256_ctr:
+ case NID_camellia_192_ctr:
+ case NID_camellia_128_ctr:
break;
default:
goto legacy;
diff --git a/crypto/include/internal/aes_platform.h b/crypto/include/internal/ciphermode_platform.h
index 26d9fdd89a..934d8136d3 100644
--- a/crypto/include/internal/aes_platform.h
+++ b/crypto/include/internal/ciphermode_platform.h
@@ -7,8 +7,10 @@
* https://www.openssl.org/source/license.html
*/
-#ifndef HEADER_INTERNAL_AES_PLATFORM_H
-# define HEADER_INTERNAL_AES_PLATFORM_H
+#ifndef HEADER_INTERNAL_CIPHERMODE_PLATFORM_H
+# define HEADER_INTERNAL_CIPHERMODE_PLATFORM_H
+
+# include "openssl/aes.h"
# ifdef VPAES_ASM
int vpaes_set_encrypt_key(const unsigned char *userKey, int bits,
@@ -189,6 +191,37 @@ void gcm_ghash_avx(u64 Xi[2], const u128 Htable[16], const u8 *in, size_t len);
/* Fujitsu SPARC64 X support */
extern unsigned int OPENSSL_sparcv9cap_P[];
# include "sparc_arch.h"
+
+# ifndef OPENSSL_NO_CAMELLIA
+# define SPARC_CMLL_CAPABLE (OPENSSL_sparcv9cap_P[1] & CFR_CAMELLIA)
+
+void cmll_t4_set_key(const unsigned char *key, int bits, CAMELLIA_KEY *ks);
+void cmll_t4_encrypt(const unsigned char *in, unsigned char *out,
+ const CAMELLIA_KEY *key);
+void cmll_t4_decrypt(const unsigned char *in, unsigned char *out,
+ const CAMELLIA_KEY *key);
+
+void cmll128_t4_cbc_encrypt(const unsigned char *in, unsigned char *out,
+ size_t len, const CAMELLIA_KEY *key,
+ unsigned char *ivec);
+void cmll128_t4_cbc_decrypt(const unsigned char *in, unsigned char *out,
+ size_t len, const CAMELLIA_KEY *key,
+ unsigned char *ivec);
+void cmll256_t4_cbc_encrypt(const unsigned char *in, unsigned char *out,
+ size_t len, const CAMELLIA_KEY *key,
+ unsigned char *ivec);
+void cmll256_t4_cbc_decrypt(const unsigned char *in, unsigned char *out,
+ size_t len, const CAMELLIA_KEY *key,
+ unsigned char *ivec);
+void cmll128_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out,
+ size_t blocks, const CAMELLIA_KEY *key,
+ unsigned char *ivec);
+void cmll256_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out,
+ size_t blocks, const CAMELLIA_KEY *key,
+ unsigned char *ivec);
+# endif /* OPENSSL_NO_CAMELLIA */
+
+
# define SPARC_AES_CAPABLE (OPENSSL_sparcv9cap_P[1] & CFR_AES)
# define HWAES_CAPABLE (OPENSSL_sparcv9cap_P[0] & SPARCV9_FJAESX)
# define HWAES_set_encrypt_key aes_fx_set_encrypt_key
@@ -398,4 +431,4 @@ void HWAES_ocb_decrypt(const unsigned char *in, unsigned char *out,
# endif /* HWAES_CAPABLE */
-#endif /* HEADER_INTERNAL_AES_PLATFORM_H */
+#endif /* HEADER_INTERNAL_CIPHERMODE_PLATFORM_H */