| /***************************************************************************** |
| * Copyright Statement: |
| * -------------------- |
| * This software is protected by Copyright and the information contained |
| * herein is confidential. The software may not be copied and the information |
| * contained herein may not be used or disclosed except with the written |
| * permission of MediaTek Inc. (C) 2012 |
| * |
| * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| * |
| * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| * |
| * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| * |
| *****************************************************************************/ |
| |
| /******************************************************************************* |
| * Filename: |
| * --------- |
| * cal_public_apis.h |
| * |
| * Project: |
| * -------- |
| * UMOLYE |
| * |
| * Description: |
| * ------------ |
| * Defines crypto abstraction layer interface |
| * |
| * Author: |
| * ------- |
| * ------- |
| * |
| * ========================================================================== |
| * $Log$ * |
| * |
| * |
| ****************************************************************************/ |
| #ifndef __CAL_PUBLIC_APIS_H__ |
| #define __CAL_PUBLIC_APIS_H__ |
| |
| #include "crypto_struct.h" |
| #include "kal_general_types.h" |
| |
| #define CAL_ENCRYPT 1 |
| #define CAL_DECRYPT 0 |
| |
| #define CAL_FLAG_DISABLE_PADDING 0x00000001 |
| |
| typedef enum{ |
| CAL_ALGO_ENC_START, |
| CAL_ALGO_ENC_NULL = CAL_ALGO_ENC_START, |
| CAL_ALGO_ENC_DES_CBC, |
| CAL_ALGO_ENC_DES_EDE3, //Triple DES in ECB mode |
| CAL_ALGO_ENC_DES_EDE3_CBC, |
| CAL_ALGO_ENC_AES_128_CBC, |
| CAL_ALGO_ENC_AES_192_CBC, |
| CAL_ALGO_ENC_AES_256_CBC, |
| |
| CAL_ALGO_ENC_AES_128_GCM, |
| CAL_ALGO_ENC_AES_192_GCM, |
| CAL_ALGO_ENC_AES_256_GCM, |
| CAL_ALGO_ENC_AES_128_CCM, |
| CAL_ALGO_ENC_AES_192_CCM, |
| CAL_ALGO_ENC_AES_256_CCM, |
| |
| CAL_ALGO_ENC_AES_128_CTR, |
| CAL_ALGO_ENC_AES_192_CTR, |
| CAL_ALGO_ENC_AES_256_CTR, |
| |
| CAL_ALGO_ENC_CAMELLIA_128_CBC, |
| CAL_ALGO_ENC_CAMELLIA_192_CBC, |
| CAL_ALGO_ENC_CAMELLIA_256_CBC, |
| CAL_ALGO_ENC_CAMELLIA_128_CCM, |
| CAL_ALGO_ENC_CAMELLIA_192_CCM, |
| CAL_ALGO_ENC_CAMELLIA_256_CCM, |
| CAL_ALGO_ENC_CAMELLIA_128_CTR, |
| CAL_ALGO_ENC_CAMELLIA_192_CTR, |
| CAL_ALGO_ENC_CAMELLIA_256_CTR, |
| #ifndef OPENSSL_NO_IDEA |
| CAL_ALGO_ENC_IDEA_CBC, |
| #endif |
| CAL_ALGO_ENC_CAST_CBC, |
| |
| CAL_ALGO_ENC_BLOWFISH_CBC, |
| CAL_ALGO_ENC_RC5_CBC, |
| CAL_ALGO_ENC_CHACHA20_POLY1305, |
| |
| CAL_ALGO_ENC_END, |
| /*Integrity Algos Start*/ |
| CAL_ALGO_INT_START = CAL_ALGO_ENC_END, |
| CAL_ALGO_INT_HMAC_MD5, |
| CAL_ALGO_INT_HMAC_SHA1, |
| CAL_ALGO_INT_HMAC_SHA256, |
| CAL_ALGO_INT_HMAC_SHA384, |
| CAL_ALGO_INT_HMAC_SHA512, |
| CAL_ALGO_INT_AES_128_GMAC, |
| CAL_ALGO_INT_AES_192_GMAC, |
| CAL_ALGO_INT_AES_256_GMAC, |
| CAL_ALGO_INT_END, |
| |
| CAL_ALGO_DIGEST_START, |
| CAL_ALGO_DIGEST_SHA1 = CAL_ALGO_DIGEST_START, |
| CAL_ALGO_DIGEST_SHA256, |
| CAL_ALGO_DIGEST_SHA384, |
| CAL_ALGO_DIGEST_SHA512, |
| CAL_ALGO_DIGEST_END, |
| |
| }cal_algo_type_t; |
| |
| typedef enum{ |
| CAL_SIGNATURE_SCHEME_START, |
| CAL_SIGNATURE_RSA_SHA1, |
| CAL_SIGNATURE_RSA_SHA256, |
| CAL_SIGNATURE_RSA_SHA384, |
| CAL_SIGNATURE_RSA_SHA512, |
| |
| CAL_SIGNATURE_ECDSA_256, |
| CAL_SIGNATURE_ECDSA_384, |
| CAL_SIGNATURE_ECDSA_521, |
| } cal_signature_scheme_type_t; |
| |
| kal_int32 cal_cipher_encrypt(cal_algo_type_t algo, const cipher_encrypt_in_para_struct *in, cipher_encrypt_out_para_struct *out, kal_int32 flags); |
| |
| kal_int32 cal_cipher_decrypt(cal_algo_type_t algo, const cipher_decrypt_in_para_struct *in, cipher_decrypt_out_para_struct *out, kal_int32 flags); |
| |
| kal_int32 cal_generate_hmac(cal_algo_type_t md, const generate_hmac_in_para_struct *in, generate_hmac_out_para_struct *out); |
| |
| kal_int32 cal_generate_prn(cal_algo_type_t md, const generate_prn_in_para_struct *in, generate_prn_out_para_struct *out); |
| |
| kal_int32 cal_generate_message_digest(const cal_algo_type_t algo, const message_digest_in_para_struct *in, message_digest_out_para_struct *out, kal_int32 flags); |
| |
| kal_int32 cal_generate_gmac(cal_algo_type_t cipher, const kal_uint8 *data, const kal_int32 data_len, const kal_uint8 * key, const kal_uint8 * iv, kal_uint8 *tag); |
| |
| kal_int32 cal_generate_dh_public_key(pkey_generate_dh_key_in_para_struct *in, pkey_generate_dh_key_out_para_struct *out); |
| |
| kal_int32 cal_verify_signature(pkey_verify_signature_in_para_struct *in); |
| |
| kal_int32 cal_compute_dh_shared_secret(pkey_compute_dh_secret_in_struct *in, pkey_compute_dh_secret_out_struct *out); |
| |
| void cal_abort_dh_key(void *dh); |
| |
| void cal_sha1_transform(kal_uint32 *state, const kal_uint8 data[64]); |
| |
| kal_int32 cal_generate_cmac(cal_algo_type_t cipher, pkey_generate_cmac_in_para_struct *in, pkey_generate_cmac_out_para_struct *out); |
| |
| /*Used in UT*/ |
| void print_cipher_info(cal_algo_type_t cipher); |
| |
| void print_md_info(cal_algo_type_t md); |
| |
| |
| #endif // __CAL_PUBLIC_APISH__ |