/*
 * Copyright (C) 2021 Samsung Electronics. Co. Ltd,
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __SKPM_CRYPTO_UTIL_H__
#define __SKPM_CRYPTO_UTIL_H__

#include "platform.h"
#include "crypto_module.h"

int leaf_blob_verify( const uint8_t* blob, const size_t blob_size );
void generateCsr(p_cmd_t cmd, p_rsp_t rsp);

STATUS extractRawSigFromAsn1WithEcc(uint8_t *sig, uint32_t sig_len, uint8_t *raw_sig_r, uint32_t *raw_sig_r_size, uint8_t *raw_sig_s, uint32_t *raw_sig_s_size);
STATUS rebuildAsn1FromRawSigWithEcc(uint8_t *raw_sig_r, uint32_t raw_sig_r_size, uint8_t *raw_sig_s, uint32_t raw_sig_s_size, uint8_t *sig, uint32_t *sig_len);

void encodeAsn1EccPrivateKey(ecc_key_t key_info, uint8_t *key_block, uint16_t *key_blockSize);
void encodeAsn1RsaPrivateKey(rsa_key_t key_info, uint8_t *key_block, uint16_t *key_blockSize);

#endif
