1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef CERT_MANAGER_KEY_OPERATION_H 17 #define CERT_MANAGER_KEY_OPERATION_H 18 19 #include "cm_type.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 enum CmSignVerifyCmd { 26 SIGN_VERIFY_CMD_UPDATE, 27 SIGN_VERIFY_CMD_FINISH, 28 SIGN_VERIFY_CMD_ABORT, 29 }; 30 31 struct CmKeyProperties { 32 uint32_t algType; 33 uint32_t keySize; 34 uint32_t padding; 35 uint32_t digest; 36 uint32_t purpose; 37 }; 38 39 int32_t CmKeyOpGenMacKey(const struct CmBlob *alias); 40 41 int32_t CmKeyOpGenMacKeyIfNotExist(const struct CmBlob *alias); 42 43 int32_t CmKeyOpDeleteKey(const struct CmBlob *alias); 44 45 int32_t CmKeyOpCalcMac(const struct CmBlob *alias, const struct CmBlob *srcData, struct CmBlob *mac); 46 47 int32_t CmKeyOpImportKey(const struct CmBlob *alias, const struct CmKeyProperties *properties, 48 const struct CmBlob *keyPair); 49 50 int32_t CmKeyOpInit(const struct CmContext *context, const struct CmBlob *alias, const struct CmSignatureSpec *spec, 51 struct CmBlob *handle); 52 53 int32_t CmKeyOpProcess(enum CmSignVerifyCmd cmdId, const struct CmContext *context, const struct CmBlob *handle, 54 const struct CmBlob *inData, struct CmBlob *outData); 55 56 #ifdef __cplusplus 57 } 58 #endif 59 60 #endif /* CERT_MANAGER_KEY_OPERATION_H */ 61 62