117f01e99SJung-uk Kim /* 2*b077aed3SPierre Pronchery * Copyright 2006-2021 The OpenSSL Project Authors. All Rights Reserved. 317f01e99SJung-uk Kim * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. 417f01e99SJung-uk Kim * 5*b077aed3SPierre Pronchery * Licensed under the Apache License 2.0 (the "License"). You may not use 617f01e99SJung-uk Kim * this file except in compliance with the License. You can obtain a copy 717f01e99SJung-uk Kim * in the file LICENSE in the source distribution or at 817f01e99SJung-uk Kim * https://www.openssl.org/source/license.html 917f01e99SJung-uk Kim */ 1017f01e99SJung-uk Kim 1117f01e99SJung-uk Kim /* Copyright (c) 2017 National Security Research Institute. All rights reserved. */ 1217f01e99SJung-uk Kim 1317f01e99SJung-uk Kim #ifndef OSSL_CRYPTO_ARIA_H 1417f01e99SJung-uk Kim # define OSSL_CRYPTO_ARIA_H 15*b077aed3SPierre Pronchery # pragma once 1617f01e99SJung-uk Kim 1717f01e99SJung-uk Kim # include <openssl/opensslconf.h> 1817f01e99SJung-uk Kim 1917f01e99SJung-uk Kim # ifdef OPENSSL_NO_ARIA 2017f01e99SJung-uk Kim # error ARIA is disabled. 2117f01e99SJung-uk Kim # endif 2217f01e99SJung-uk Kim 2317f01e99SJung-uk Kim # define ARIA_ENCRYPT 1 2417f01e99SJung-uk Kim # define ARIA_DECRYPT 0 2517f01e99SJung-uk Kim 2617f01e99SJung-uk Kim # define ARIA_BLOCK_SIZE 16 /* Size of each encryption/decryption block */ 2717f01e99SJung-uk Kim # define ARIA_MAX_KEYS 17 /* Number of keys needed in the worst case */ 2817f01e99SJung-uk Kim 2917f01e99SJung-uk Kim typedef union { 3017f01e99SJung-uk Kim unsigned char c[ARIA_BLOCK_SIZE]; 3117f01e99SJung-uk Kim unsigned int u[ARIA_BLOCK_SIZE / sizeof(unsigned int)]; 3217f01e99SJung-uk Kim } ARIA_u128; 3317f01e99SJung-uk Kim 3417f01e99SJung-uk Kim typedef unsigned char ARIA_c128[ARIA_BLOCK_SIZE]; 3517f01e99SJung-uk Kim 3617f01e99SJung-uk Kim struct aria_key_st { 3717f01e99SJung-uk Kim ARIA_u128 rd_key[ARIA_MAX_KEYS]; 3817f01e99SJung-uk Kim unsigned int rounds; 3917f01e99SJung-uk Kim }; 4017f01e99SJung-uk Kim typedef struct aria_key_st ARIA_KEY; 4117f01e99SJung-uk Kim 4217f01e99SJung-uk Kim 43*b077aed3SPierre Pronchery int ossl_aria_set_encrypt_key(const unsigned char *userKey, const int bits, 4417f01e99SJung-uk Kim ARIA_KEY *key); 45*b077aed3SPierre Pronchery int ossl_aria_set_decrypt_key(const unsigned char *userKey, const int bits, 4617f01e99SJung-uk Kim ARIA_KEY *key); 4717f01e99SJung-uk Kim 48*b077aed3SPierre Pronchery void ossl_aria_encrypt(const unsigned char *in, unsigned char *out, 4917f01e99SJung-uk Kim const ARIA_KEY *key); 5017f01e99SJung-uk Kim 5117f01e99SJung-uk Kim #endif 52