| /***************************************************************************** |
| * 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: |
| * --------- |
| * crypto_struct.h |
| * |
| * Project: |
| * -------- |
| * UMOLYE |
| * |
| * Description: |
| * ------------ |
| * Defines crypto engine service ILM structure |
| * |
| * Author: |
| * ------- |
| * ------- |
| * |
| * ========================================================================== |
| * $Log$ * |
| * |
| * |
| ****************************************************************************/ |
| #ifndef __CRYPTO_STRUCT_H__ |
| #define __CRYPTO_STRUCT_H__ |
| |
| #include "kal_public_defs.h" |
| #include "kal_public_api.h" |
| #include "kal_general_types.h" |
| |
| typedef enum{ |
| CAL_EC_CURVE_START, |
| CAL_EC_CURVE_NSIT_P_256 = CAL_EC_CURVE_START, /* NID_X9_62_prime256v1 */ |
| CAL_EC_CURVE_NSIT_P_384, /* NID_secp384r1 */ |
| CAL_EC_CURVE_NSIT_P_521, /* NID_secp521r1 */ |
| CAL_EC_CURVE_END |
| }cal_ec_named_curves_t; |
| |
| |
| typedef enum{ |
| CAL_PKEY_TYPE_START, |
| CAL_PKEY_TYPE_DH = CAL_PKEY_TYPE_START, |
| CAL_PKEY_TYPE_RSA, |
| CAL_PKEY_TYPE_DSA, |
| CAL_PKEY_TYPE_EC, |
| CAL_PKEY_TYPE_END |
| }cal_pkey_types_t; |
| |
| typedef struct |
| { |
| kal_int32 data_len; |
| kal_int32 key_len; |
| kal_int32 iv_len; |
| kal_int32 aad_len; |
| kal_int32 tag_len; |
| kal_uint8 *data; /* Plain text */ |
| kal_uint8 *key; |
| kal_uint8 *iv; /* Initialization vector */ |
| kal_uint8 *aad; /* Additional Authentical Data */ |
| } cipher_encrypt_in_para_struct; |
| |
| typedef struct{ |
| kal_int32 tag_len; |
| kal_uint8 *data; |
| kal_uint8 *tag; |
| } cipher_encrypt_out_para_struct; |
| |
| typedef struct |
| { |
| kal_int32 data_len; |
| kal_int32 key_len; |
| kal_int32 iv_len; |
| kal_int32 aad_len; |
| kal_int32 tag_len; |
| kal_uint8 *data; /* Encrypted text */ |
| kal_uint8 *key; |
| kal_uint8 *iv; /* Initialization vector */ |
| kal_uint8 *aad; /* Additional Authentical Data */ |
| kal_uint8 *tag; |
| } cipher_decrypt_in_para_struct; |
| |
| typedef struct{ |
| kal_uint8 *data; |
| } cipher_decrypt_out_para_struct; |
| |
| |
| typedef struct{ |
| kal_int32 data_len; |
| kal_int32 key_len; |
| kal_uint8 *data; /* Plain text */ |
| kal_uint8 *key; |
| } generate_hmac_in_para_struct; |
| |
| typedef struct{ |
| kal_uint8 *data; |
| } generate_hmac_out_para_struct; |
| |
| typedef generate_hmac_in_para_struct generate_prn_in_para_struct; |
| typedef generate_hmac_out_para_struct generate_prn_out_para_struct; |
| |
| typedef struct{ |
| kal_int32 message_len; |
| kal_uint8 *message; |
| } message_digest_in_para_struct; |
| |
| typedef struct{ |
| kal_uint32 digest_len; |
| kal_uint8 *digest; |
| } message_digest_out_para_struct; |
| |
| typedef struct{ |
| kal_int32 message_len; |
| kal_int32 key_len; |
| kal_uint8 *message; /* Plain text */ |
| kal_uint8 *key; |
| |
| } pkey_generate_cmac_in_para_struct; |
| |
| typedef struct{ |
| kal_int32 mac_len; |
| kal_uint8 *mac; |
| } pkey_generate_cmac_out_para_struct; |
| |
| typedef struct{ |
| kal_uint32 scheme; /* Signature scheme cal_signature_scheme_type_t */ |
| kal_int32 pubkey_len; |
| kal_int32 pubkey_exp_len; |
| kal_int32 msg_len; |
| kal_int32 signature_len; |
| kal_uint8 *pubkey; /* For ECDSA : Public key, For RSA : RSA modulus */ |
| kal_uint8 *pubkey_exp; /* For ECDSA : NULL, For RSA : RSA public exponent */ |
| kal_uint8 *msg; |
| kal_uint8 *signature; |
| } pkey_verify_signature_in_para_struct; |
| |
| typedef struct{ |
| kal_int32 p_len; |
| kal_int32 g_len; |
| kal_uint8 *p; |
| kal_uint8 *g; |
| } pkey_generate_dh_key_in_para_struct; |
| |
| typedef struct |
| { |
| kal_int32 pub_len; |
| void *dh; |
| kal_uint8 *pub; |
| } pkey_generate_dh_key_out_para_struct; |
| |
| typedef struct |
| { |
| kal_int32 peer_pub_len; |
| void *dh; |
| kal_uint8 *peer_pub; |
| } pkey_compute_dh_secret_in_struct; |
| |
| typedef struct |
| { |
| kal_int32 secret_len; |
| kal_uint8 *secret; |
| } pkey_compute_dh_secret_out_struct; |
| |
| /************************************************** |
| * CRYPTO ilm struct |
| **************************************************/ |
| |
| // MSG_ID_CRPTBRG_CIPHER_ENCRYPT_REQ |
| typedef struct |
| { |
| LOCAL_PARA_HDR |
| |
| kal_uint32 req_id; |
| kal_uint32 algo; /* Crypto algorithm to be used for decryption */ |
| kal_uint32 flags; |
| cipher_encrypt_in_para_struct in; |
| kal_uint8 *out; /* Cipher text */ |
| kal_uint8 *tag; /* Tag/Digest */ |
| |
| } crptbrg_cipher_encrypt_req_struct; |
| |
| // MSG_ID_CRPTBRG_CIPHER_DECRYPT_REQ |
| typedef struct |
| { |
| LOCAL_PARA_HDR |
| |
| kal_uint32 req_id; |
| kal_uint32 algo; /* Crypto algorithm to be used for decryption */ |
| kal_uint32 flags; |
| cipher_decrypt_in_para_struct in; |
| kal_uint8 *out; /* Plain text */ |
| } crptbrg_cipher_decrypt_req_struct; |
| |
| |
| // MSG_ID_CRPTBRG_GENERATE_HMAC_REQ |
| typedef struct |
| { |
| LOCAL_PARA_HDR |
| |
| kal_uint32 req_id; |
| kal_uint32 algo; /* Crypto algorithm to be used for encryption */ |
| generate_hmac_in_para_struct in; |
| kal_uint8 *out; |
| } crptbrg_generate_hmac_req_struct; |
| |
| // MSG_ID_CRPTBRG_GENERATE_PRN_REQ |
| typedef crptbrg_generate_hmac_req_struct crptbrg_generate_prn_req_struct; |
| |
| |
| // MSG_ID_CRPTBRG_VERIFY_SIGNATURE_REQ |
| typedef struct |
| { |
| LOCAL_PARA_HDR |
| |
| kal_uint32 req_id; |
| pkey_verify_signature_in_para_struct in; |
| |
| } crptbrg_verify_signature_req_struct; |
| |
| // MSG_ID_CRPTBRG_GENERATE_DH_KEY_REQ |
| typedef struct |
| { |
| LOCAL_PARA_HDR |
| |
| kal_uint32 req_id; |
| pkey_generate_dh_key_in_para_struct in; |
| kal_uint8 *out; /* Public key */ |
| |
| } crptbrg_generate_dh_key_req_struct; |
| |
| // MSG_ID_CRPTBRG_COMPUTE_DH_SECRET_REQ |
| typedef struct |
| { |
| LOCAL_PARA_HDR |
| |
| kal_uint32 req_id; |
| pkey_compute_dh_secret_in_struct in; |
| kal_uint8 *out; /* Shared secret */ |
| |
| } crptbrg_compute_dh_secret_req_struct; |
| |
| // MSG_ID_CRPTBRG_ABORT_DH_KEY_IND |
| typedef struct |
| { |
| LOCAL_PARA_HDR |
| void *dh; |
| } crptbrg_abort_dh_key_ind_struct; |
| |
| // MSG_ID_CRPTBRG_CIPHER_ENCRYPT_CNF |
| typedef struct |
| { |
| LOCAL_PARA_HDR |
| |
| kal_uint32 req_id; |
| kal_int32 out_len; |
| kal_int32 tag_len; |
| cipher_encrypt_in_para_struct in; /* Input struct back to app to free memory */ |
| kal_uint8 *out; /* Cipher text */ |
| kal_uint8 *tag; |
| } crptbrg_cipher_encrypt_cnf_struct; |
| |
| // MSG_ID_CRPTBRG_CIPHER_DECRYPT_CNF |
| typedef struct |
| { |
| LOCAL_PARA_HDR |
| |
| kal_uint32 req_id; |
| kal_int32 out_len; |
| cipher_decrypt_in_para_struct in; /* Input struct back to app to free memory */ |
| kal_uint8 *out; /* Plain text */ |
| } crptbrg_cipher_decrypt_cnf_struct; |
| |
| |
| // MSG_ID_CRPTBRG_GENERATE_HMAC_CNF |
| typedef struct |
| { |
| LOCAL_PARA_HDR |
| |
| kal_uint32 req_id; |
| kal_int32 out_len; |
| generate_hmac_in_para_struct in; /* Input struct back to app to free memory */ |
| kal_uint8 *out; |
| } crptbrg_generate_hmac_cnf_struct; |
| |
| // MSG_ID_CRPTBRG_GENERATE_PRN_CNF |
| typedef crptbrg_generate_hmac_cnf_struct crptbrg_generate_prn_cnf_struct; |
| |
| // MSG_ID_CRPTBRG_VERIFY_SIGNATURE_CNF |
| typedef struct |
| { |
| LOCAL_PARA_HDR |
| |
| kal_uint32 req_id; |
| kal_uint32 out; /* Verify success or fail; 1 : Success, everything else is fail */ |
| pkey_verify_signature_in_para_struct in; |
| |
| } crptbrg_verify_signature_cnf_struct; |
| |
| // MSG_ID_CRPTBRG_GENERATE_DH_KEY_CNF |
| typedef struct |
| { |
| LOCAL_PARA_HDR |
| |
| kal_uint32 req_id; |
| kal_int32 out_len; |
| pkey_generate_dh_key_in_para_struct in; /* Input struct back to app to free memory */ |
| kal_uint8 *out; /* Public key */ |
| void *dh; /* Needed by CAL to compute shared secret */ |
| } crptbrg_generate_dh_key_cnf_struct; |
| |
| // MSG_ID_CRPTBRG_COMPUTE_DH_SECRET_CNF |
| typedef struct |
| { |
| LOCAL_PARA_HDR |
| |
| kal_uint32 req_id; |
| kal_int32 out_len; |
| pkey_compute_dh_secret_in_struct in; /* Input struct back to app to free memory */ |
| kal_uint8 *out; /* Shared secret */ |
| |
| } crptbrg_compute_dh_secret_cnf_struct; |
| |
| typedef struct |
| { |
| LOCAL_PARA_HDR |
| kal_uint32 req_id; |
| kal_uint32 algo; /* Crypto algorithm to be used for decryption */ |
| pkey_generate_cmac_in_para_struct in; |
| kal_uint8 *out; /* memory for cmac*/ |
| } crptbrg_generate_cmac_req_struct; |
| |
| typedef struct |
| { |
| LOCAL_PARA_HDR |
| kal_uint32 req_id; |
| kal_int32 out_len; |
| pkey_generate_cmac_in_para_struct in; /* Input struct back to app to free memory */ |
| kal_uint8 *out; /* cmac */ |
| } crptbrg_generate_cmac_cnf_struct; |
| |
| |
| |
| /*********************************************************************** |
| * CRYPTO Internal Task ilm structs : NOT TO BE USED BY OTHER MODULES * |
| ***********************************************************************/ |
| |
| // MSG_ID_CRYPTO_INTERNAL_GENERATE_DH_KEY_REQ |
| typedef struct |
| { |
| LOCAL_PARA_HDR |
| |
| kal_uint32 src_mod_id; |
| kal_uint32 req_id; |
| pkey_generate_dh_key_in_para_struct in; |
| kal_uint8 *out; /* Public key */ |
| |
| } crypto_internal_generate_dh_key_req_struct; |
| |
| // MSG_ID_CRYPTO_INTERNAL_COMPUTE_DH_SECRET_REQ |
| typedef struct |
| { |
| LOCAL_PARA_HDR |
| |
| kal_uint32 src_mod_id; |
| kal_uint32 req_id; |
| pkey_compute_dh_secret_in_struct in; |
| kal_uint8 *out; /* Shared secret */ |
| |
| } crypto_internal_compute_dh_secret_req_struct; |
| |
| |
| #endif // __CRYPTO_STRUCT_H__ |