119e95205Sopenharmony_ci/* 219e95205Sopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd. 319e95205Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 419e95205Sopenharmony_ci * you may not use this file except in compliance with the License. 519e95205Sopenharmony_ci * You may obtain a copy of the License at 619e95205Sopenharmony_ci * 719e95205Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 819e95205Sopenharmony_ci * 919e95205Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1019e95205Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1119e95205Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1219e95205Sopenharmony_ci * See the License for the specific language governing permissions and 1319e95205Sopenharmony_ci * limitations under the License. 1419e95205Sopenharmony_ci */ 1519e95205Sopenharmony_ci 1619e95205Sopenharmony_ci#ifndef SMP_H 1719e95205Sopenharmony_ci#define SMP_H 1819e95205Sopenharmony_ci 1919e95205Sopenharmony_ci#include <stdbool.h> 2019e95205Sopenharmony_ci#include <stddef.h> 2119e95205Sopenharmony_ci#include <stdint.h> 2219e95205Sopenharmony_ci#include <stdlib.h> 2319e95205Sopenharmony_ci 2419e95205Sopenharmony_ci#include "btstack.h" 2519e95205Sopenharmony_ci#include "securec.h" 2619e95205Sopenharmony_ci 2719e95205Sopenharmony_ci#ifdef __cplusplus 2819e95205Sopenharmony_ciextern "C" { 2919e95205Sopenharmony_ci#endif 3019e95205Sopenharmony_ci 3119e95205Sopenharmony_ci// true: Pairing using hardware AES-128 encryption algorithm 3219e95205Sopenharmony_ci// false: Pairing using software AES-128 encryption algorithm 3319e95205Sopenharmony_ci#define SMP_USING_HW_AES128_PAIR (false) 3419e95205Sopenharmony_ci 3519e95205Sopenharmony_ci// true: Generating Signature using hardware AES-128 encryption algorithm 3619e95205Sopenharmony_ci// false: Generating Signature using software AES-128 encryption algorithm 3719e95205Sopenharmony_ci#define SMP_USING_HW_AES128_SIGN (false) 3819e95205Sopenharmony_ci 3919e95205Sopenharmony_ci// true: Generating/Resolving RPA using hardware AES-128 encryption algorithm 4019e95205Sopenharmony_ci// false: Generating/Resolving RPA using software AES-128 encryption algorithm 4119e95205Sopenharmony_ci#define SMP_USING_HW_AES128_RPA (false) 4219e95205Sopenharmony_ci 4319e95205Sopenharmony_ci#define SMP_PAIR_STATUS_SUCCESS 0x00 4419e95205Sopenharmony_ci#define SMP_PAIR_STATUS_FAILED 0x01 4519e95205Sopenharmony_ci 4619e95205Sopenharmony_ci#define SMP_ENCRYPT_STATUS_SUCCESS 0x00 4719e95205Sopenharmony_ci#define SMP_ENCRYPT_STATUS_FAILED 0x01 4819e95205Sopenharmony_ci 4919e95205Sopenharmony_ci#define SMP_GENERATE_SIGN_STATUS_SUCCESS 0x00 5019e95205Sopenharmony_ci#define SMP_GENERATE_SIGN_STATUS_FAILED 0x01 5119e95205Sopenharmony_ci 5219e95205Sopenharmony_ci#define SMP_GENERATE_RPA_STATUS_SUCCESS 0x00 5319e95205Sopenharmony_ci#define SMP_GENERATE_RPA_STATUS_FAILED 0x01 5419e95205Sopenharmony_ci 5519e95205Sopenharmony_ci#define SMP_RESOLVE_RPA_STATUS_SUCCESS 0x00 5619e95205Sopenharmony_ci#define SMP_RESOLVE_RPA_STATUS_FAILED 0x01 5719e95205Sopenharmony_ci 5819e95205Sopenharmony_ci#define SMP_RESOLVE_RPA_RESULT_YES 0x01 5919e95205Sopenharmony_ci#define SMP_RESOLVE_RPA_RESULT_NO 0x00 6019e95205Sopenharmony_ci 6119e95205Sopenharmony_ci#define SMP_GENERATE_SC_OOB_DATA_SUCCESS 0x00 6219e95205Sopenharmony_ci#define SMP_GENERATE_SC_OOB_DATA_FAILED 0x01 6319e95205Sopenharmony_ci 6419e95205Sopenharmony_ci#define SMP_SUCCESS BT_SUCCESS /// < SMP error code success 6519e95205Sopenharmony_ci#define SMP_ERR_NOT_ENABLE BT_BAD_STATUS /// < SMP error code module not initialize 6619e95205Sopenharmony_ci#define SMP_ERR_INVAL_PARAM BT_BAD_PARAM /// < SMP error code invalid parameter 6719e95205Sopenharmony_ci#define SMP_ERR_INVAL_STATE BT_BAD_STATUS /// < SMP error code invalid state 6819e95205Sopenharmony_ci#define SMP_ERR_REPEATED BT_ALREADY /// < SMP error code repeated action 6919e95205Sopenharmony_ci#define SMP_ERR_OUT_OF_RES BT_NO_MEMORY /// < SMP error code out of resource 7019e95205Sopenharmony_ci#define SMP_ERR_REMOTE_ACTION BT_OPERATION_FAILED /// < SMP error code communication failed 7119e95205Sopenharmony_ci 7219e95205Sopenharmony_ci#define SMP_PAIR_METHOD_JUST_WORK 0x00 7319e95205Sopenharmony_ci// Data Type: uint32_t 7419e95205Sopenharmony_ci#define SMP_PAIR_METHOD_PASSKEY_DISPLAY 0x02 7519e95205Sopenharmony_ci// Data Type: uint32_t 7619e95205Sopenharmony_ci#define SMP_PAIR_METHOD_PASSKEY_ENTRY 0x03 7719e95205Sopenharmony_ci// Data Type: uint32_t 7819e95205Sopenharmony_ci#define SMP_PAIR_METHOD_NUMERIC_COMPARISON 0x04 7919e95205Sopenharmony_ci#define SMP_PAIR_METHOD_OOB_LEGACY 0x05 // Data Type: uint8_t array (16 bytes) 8019e95205Sopenharmony_ci#define SMP_PAIR_METHOD_OOB_SC_BOTH_SIDE_SEND_RECV 0x06 // Data Type: uint8_t array (38 bytes) 8119e95205Sopenharmony_ci#define SMP_PAIR_METHOD_OOB_SC_LOCAL_SEND_PEER_RECV 0x07 // Data Type: uint8_t array (38 bytes) 8219e95205Sopenharmony_ci#define SMP_PAIR_METHOD_OOB_SC_LOCAL_RECV_PEER_SEND 0x08 // Data Type: uint8_t array (38 bytes) 8319e95205Sopenharmony_ci 8419e95205Sopenharmony_ci#define SMP_BONDED_FLAG_NO 0x00 8519e95205Sopenharmony_ci#define SMP_BONDED_FLAG_YES 0x01 8619e95205Sopenharmony_ci 8719e95205Sopenharmony_ci#define SMP_AUTH_FLAG_NO 0x00 8819e95205Sopenharmony_ci#define SMP_AUTH_FLAG_YES 0x01 8919e95205Sopenharmony_ci 9019e95205Sopenharmony_ci#define SMP_PAIR_TYPE_LEGACY 0x00 9119e95205Sopenharmony_ci#define SMP_PAIR_TYPE_SECURE_CONNECTION 0x01 9219e95205Sopenharmony_ci 9319e95205Sopenharmony_ci#define SMP_PAIR_FAILED_NO_FAILED 0x00 9419e95205Sopenharmony_ci#define SMP_PAIR_FAILED_PASSKEY_ENTRY 0x01 9519e95205Sopenharmony_ci#define SMP_PAIR_FAILED_OOB_NOT_AVAILABLE 0x02 9619e95205Sopenharmony_ci#define SMP_PAIR_FAILED_AUTH_REQ 0x03 9719e95205Sopenharmony_ci#define SMP_PAIR_FAILED_CONFIRM_VALUE 0x04 9819e95205Sopenharmony_ci#define SMP_PAIR_FAILED_PAIRING_NOT_SUPPORTED 0x05 9919e95205Sopenharmony_ci#define SMP_PAIR_FAILED_ENC_KEY_SIZE 0x06 10019e95205Sopenharmony_ci#define SMP_PAIR_FAILED_ENC_CMD_NOT_SUPPORTED 0x07 10119e95205Sopenharmony_ci#define SMP_PAIR_FAILED_UNSPECIFIED_REASION 0x08 10219e95205Sopenharmony_ci#define SMP_PAIR_FAILED_REPAETED_ATTEMPTS 0x09 10319e95205Sopenharmony_ci#define SMP_PAIR_FAILED_INVALID_PARAM 0x0A 10419e95205Sopenharmony_ci#define SMP_PAIR_FAILED_DHKEY_CHECK 0x0B 10519e95205Sopenharmony_ci#define SMP_PAIR_FAILED_NUMERIC_COMPARISON 0x0C 10619e95205Sopenharmony_ci#define SMP_PAIR_FAILED_BREDR_PAIRING_IN_PROGRESS 0x0D 10719e95205Sopenharmony_ci#define SMP_PAIR_FAILED_KEY_GENERATION_NOT_ALLOWED 0x0E 10819e95205Sopenharmony_ci 10919e95205Sopenharmony_ci#define SMP_IO_DISPLAY_ONLY 0x00 11019e95205Sopenharmony_ci#define SMP_IO_DISPLAY_YES_NO 0x01 11119e95205Sopenharmony_ci#define SMP_IO_KEYBOARD_ONLY 0x02 11219e95205Sopenharmony_ci#define SMP_IO_NO_INPUT_NO_OUTPUT 0x03 11319e95205Sopenharmony_ci#define SMP_IO_KEYBOARD_DISPLAY 0x04 11419e95205Sopenharmony_ci 11519e95205Sopenharmony_ci#define SMP_AUTH_REQ_NO_BONDING 0x00 11619e95205Sopenharmony_ci#define SMP_AUTH_REQ_BONDING 0x01 11719e95205Sopenharmony_ci#define SMP_AUTH_REQ_BIT_MITM 0x04 11819e95205Sopenharmony_ci#define SMP_AUTH_REQ_BIT_SC 0x08 11919e95205Sopenharmony_ci#define SMP_AUTH_REQ_BIT_KEYPRESS 0x10 12019e95205Sopenharmony_ci#define SMP_AUTH_REQ_BIT_CT2 0x20 12119e95205Sopenharmony_ci 12219e95205Sopenharmony_ci#define SMP_KEY_DIST_BIT_ENC_KEY 0x01 12319e95205Sopenharmony_ci#define SMP_KEY_DIST_BIT_ID_KEY 0x02 12419e95205Sopenharmony_ci#define SMP_KEY_DIST_BIT_SIGN_KEY 0x04 12519e95205Sopenharmony_ci 12619e95205Sopenharmony_ci#define SMP_IRK_LEN 0x10 12719e95205Sopenharmony_ci#define SMP_CSRK_LEN 0x10 12819e95205Sopenharmony_ci#define SMP_RAND_NUM_LEN 0x08 12919e95205Sopenharmony_ci#define SMP_LTK_LEN 0x10 13019e95205Sopenharmony_ci 13119e95205Sopenharmony_ci/** 13219e95205Sopenharmony_ci * @brief Pair param structure. 13319e95205Sopenharmony_ci */ 13419e95205Sopenharmony_citypedef struct { 13519e95205Sopenharmony_ci uint8_t ioCapability; 13619e95205Sopenharmony_ci uint8_t oobDataFlag; 13719e95205Sopenharmony_ci uint8_t authReq; 13819e95205Sopenharmony_ci uint8_t maxEncKeySize; 13919e95205Sopenharmony_ci uint8_t initKeyDist; 14019e95205Sopenharmony_ci uint8_t respKeyDist; 14119e95205Sopenharmony_ci} SMP_PairParam; 14219e95205Sopenharmony_ci 14319e95205Sopenharmony_ci/** 14419e95205Sopenharmony_ci * @brief Pair result structure. 14519e95205Sopenharmony_ci */ 14619e95205Sopenharmony_citypedef struct { 14719e95205Sopenharmony_ci uint8_t pairType; 14819e95205Sopenharmony_ci uint8_t bondedFlag; 14919e95205Sopenharmony_ci uint8_t authFlag; 15019e95205Sopenharmony_ci uint8_t encKeySize; 15119e95205Sopenharmony_ci uint8_t localKeyDist; 15219e95205Sopenharmony_ci uint8_t peerKeyDist; 15319e95205Sopenharmony_ci uint8_t localLTK[SMP_LTK_LEN]; 15419e95205Sopenharmony_ci uint16_t localEdiv; 15519e95205Sopenharmony_ci uint8_t localRandom[SMP_RAND_NUM_LEN]; 15619e95205Sopenharmony_ci uint8_t peerLTK[SMP_LTK_LEN]; 15719e95205Sopenharmony_ci uint16_t peerEdiv; 15819e95205Sopenharmony_ci uint8_t peerRandom[SMP_RAND_NUM_LEN]; 15919e95205Sopenharmony_ci uint8_t localIRK[SMP_IRK_LEN]; 16019e95205Sopenharmony_ci BtAddr localIdentAddr; 16119e95205Sopenharmony_ci uint8_t peerIRK[SMP_IRK_LEN]; 16219e95205Sopenharmony_ci BtAddr peerIdentAddr; 16319e95205Sopenharmony_ci uint8_t localCSRK[SMP_CSRK_LEN]; 16419e95205Sopenharmony_ci uint8_t peerCSRK[SMP_CSRK_LEN]; 16519e95205Sopenharmony_ci} SMP_PairResult; 16619e95205Sopenharmony_ci 16719e95205Sopenharmony_ci/** 16819e95205Sopenharmony_ci * @brief Security manager callback structure. 16919e95205Sopenharmony_ci */ 17019e95205Sopenharmony_citypedef struct { 17119e95205Sopenharmony_ci void (*SMP_CallbackAuthenticationRequest)(uint16_t handle, uint8_t pairMethod, const uint8_t *displayValue); 17219e95205Sopenharmony_ci void (*SMP_CallbackPairResult)(uint16_t handle, uint8_t status, const SMP_PairResult *result); 17319e95205Sopenharmony_ci void (*SMP_CallbackRemotePairRequest)(uint16_t handle, const SMP_PairParam *param); 17419e95205Sopenharmony_ci void (*SMP_CallbackRemotePairResponse)(uint16_t handle, const SMP_PairParam *param); 17519e95205Sopenharmony_ci void (*SMP_CallbackRemoteSecurityRequest)(uint16_t handle, uint8_t authReq); 17619e95205Sopenharmony_ci void (*SMP_CallbackLongTermKeyRequest)(uint16_t handle, const uint8_t *random, uint16_t ediv); 17719e95205Sopenharmony_ci void (*SMP_CallbackEncryptionComplete)(uint16_t handle, uint8_t status); 17819e95205Sopenharmony_ci void (*SMP_CallbackGenerateSignatureResult)(uint8_t status, const uint8_t *sign); 17919e95205Sopenharmony_ci void (*SMP_CallbackGenerateRPAResult)(uint8_t status, const uint8_t *addr); 18019e95205Sopenharmony_ci void (*SMP_CallbackResolveRPAResult)(uint8_t status, bool result, const uint8_t *addr, const uint8_t *irk); 18119e95205Sopenharmony_ci void (*SMP_CallbackGenerateScOobDataResult)(uint8_t status, const uint8_t *random, const uint8_t *confirm); 18219e95205Sopenharmony_ci} SMP_Callback_t; 18319e95205Sopenharmony_ci 18419e95205Sopenharmony_ci/** 18519e95205Sopenharmony_ci * @brief Set local IRk. 18619e95205Sopenharmony_ci * 18719e95205Sopenharmony_ci * @param irk Local IRK. 18819e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful; returns others if the operation fails. 18919e95205Sopenharmony_ci */ 19019e95205Sopenharmony_ciint SMP_SetIRK(const uint8_t *irk); 19119e95205Sopenharmony_ci 19219e95205Sopenharmony_ci/** 19319e95205Sopenharmony_ci * @brief Set Local Identity Address. 19419e95205Sopenharmony_ci * 19519e95205Sopenharmony_ci * @param addr Local Identity Address. 19619e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful; returns others if the operation fails. 19719e95205Sopenharmony_ci */ 19819e95205Sopenharmony_ciint SMP_SetIdentAddr(const BtAddr *addr); 19919e95205Sopenharmony_ci 20019e95205Sopenharmony_ci/** 20119e95205Sopenharmony_ci * @brief Resolve resolvable private address. 20219e95205Sopenharmony_ci * 20319e95205Sopenharmony_ci * @param addr Resolvable private address. 20419e95205Sopenharmony_ci * @param irk Saved irk. 20519e95205Sopenharmony_ci * @return Returns <b>SMP_RESOLVE_RPA_RESULT_YES</b> if the operation is successful; 20619e95205Sopenharmony_ci * returns others if the operation fails. 20719e95205Sopenharmony_ci */ 20819e95205Sopenharmony_ciint SMP_ResolveRPA(const uint8_t *addr, const uint8_t *irk); 20919e95205Sopenharmony_ci 21019e95205Sopenharmony_ci/** 21119e95205Sopenharmony_ci * @brief Resolve resolvable private address. 21219e95205Sopenharmony_ci * 21319e95205Sopenharmony_ci * @param addr Resolvable private address. 21419e95205Sopenharmony_ci * @param irk Saved irk. 21519e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful; returns others if the operation fails. 21619e95205Sopenharmony_ci */ 21719e95205Sopenharmony_ciint SMP_AsyncResolveRPA(const uint8_t *addr, const uint8_t *irk); 21819e95205Sopenharmony_ci 21919e95205Sopenharmony_ci/** 22019e95205Sopenharmony_ci * @brief Generate resolvable private address. 22119e95205Sopenharmony_ci * 22219e95205Sopenharmony_ci * @param irk Local irk. 22319e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful; returns others if the operation fails. 22419e95205Sopenharmony_ci */ 22519e95205Sopenharmony_ciint SMP_GenerateRPA(const uint8_t *irk); 22619e95205Sopenharmony_ci 22719e95205Sopenharmony_ci/** 22819e95205Sopenharmony_ci * @brief Set Secure Connection Only mode. 22919e95205Sopenharmony_ci * 23019e95205Sopenharmony_ci * @param mode Whether it is Secure Connection Only mode. 23119e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful; returns others if the operation fails. 23219e95205Sopenharmony_ci */ 23319e95205Sopenharmony_ciint SMP_SetSecureConnOnlyMode(bool mode); 23419e95205Sopenharmony_ci 23519e95205Sopenharmony_ci/** 23619e95205Sopenharmony_ci * @brief Send a Security Request to the remote device. 23719e95205Sopenharmony_ci * 23819e95205Sopenharmony_ci * @param handle ACL Connection Handle. 23919e95205Sopenharmony_ci * @param authReq Authentication Requirements Flags. 24019e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful; returns others if the operation fails. 24119e95205Sopenharmony_ci */ 24219e95205Sopenharmony_ciint SMP_SendSecurityRequestToRemote(uint16_t handle, uint8_t authReq); 24319e95205Sopenharmony_ci 24419e95205Sopenharmony_ci/** 24519e95205Sopenharmony_ci * @brief Generate signature. 24619e95205Sopenharmony_ci * 24719e95205Sopenharmony_ci * @param csrk Connection Signature Resolving Key. 24819e95205Sopenharmony_ci * @param counter Signature counter . 24919e95205Sopenharmony_ci * @param data Data that needs to be signed. 25019e95205Sopenharmony_ci * @param dataLen Data length. 25119e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful; returns others if the operation fails. 25219e95205Sopenharmony_ci */ 25319e95205Sopenharmony_ciint SMP_GenerateSignature(const uint8_t *csrk, uint32_t counter, const uint8_t *data, uint16_t dataLen); 25419e95205Sopenharmony_ci 25519e95205Sopenharmony_ci/** 25619e95205Sopenharmony_ci * @brief Start Encryption. 25719e95205Sopenharmony_ci * 25819e95205Sopenharmony_ci * @param handle ACL Connection Handle. 25919e95205Sopenharmony_ci * @param random Saved peer random. 26019e95205Sopenharmony_ci * @param ediv Saved peer ediv. 26119e95205Sopenharmony_ci * @param key Saved peer long term key. 26219e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful; returns others if the operation fails. 26319e95205Sopenharmony_ci */ 26419e95205Sopenharmony_ciint SMP_StartEncryption(uint16_t handle, const uint8_t *random, uint16_t ediv, const uint8_t *key); 26519e95205Sopenharmony_ci 26619e95205Sopenharmony_ci/** 26719e95205Sopenharmony_ci * @brief Proactively start pairing. 26819e95205Sopenharmony_ci * 26919e95205Sopenharmony_ci * @param handle ACL Connection Handle. 27019e95205Sopenharmony_ci * @param localAddr Local addr. 27119e95205Sopenharmony_ci * @param peerAddr Peer addr. 27219e95205Sopenharmony_ci * @param param Paired param. 27319e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful; returns others if the operation fails. 27419e95205Sopenharmony_ci */ 27519e95205Sopenharmony_ciint SMP_StartPair(uint16_t handle, const BtAddr *localAddr, const BtAddr *peerAddr, const SMP_PairParam *param); 27619e95205Sopenharmony_ci 27719e95205Sopenharmony_ci/** 27819e95205Sopenharmony_ci * @brief Reply authentication request. 27919e95205Sopenharmony_ci * 28019e95205Sopenharmony_ci * @param handle ACL Connection Handle. 28119e95205Sopenharmony_ci * @param accept Accept or reject. 28219e95205Sopenharmony_ci * @param rejectReason Reject Reason. 28319e95205Sopenharmony_ci * @param pairMethod Paired method. 28419e95205Sopenharmony_ci * @param entryValue Authentication value. 28519e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful; returns others if the operation fails. 28619e95205Sopenharmony_ci */ 28719e95205Sopenharmony_ciint SMP_AuthenticationRequestReply( 28819e95205Sopenharmony_ci uint16_t handle, bool accept, uint8_t rejectReason, uint8_t pairMethod, const uint8_t *entryValue); 28919e95205Sopenharmony_ci 29019e95205Sopenharmony_ci/** 29119e95205Sopenharmony_ci * @brief Reply to peer pairing request. 29219e95205Sopenharmony_ci * 29319e95205Sopenharmony_ci * @param handle ACL Connection Handle. 29419e95205Sopenharmony_ci * @param rejectReason Reject Reason. 29519e95205Sopenharmony_ci * @param localAddr Local addr. 29619e95205Sopenharmony_ci * @param peerAddr Peer addr. 29719e95205Sopenharmony_ci * @param param Paired param. 29819e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful; returns others if the operation fails. 29919e95205Sopenharmony_ci */ 30019e95205Sopenharmony_ciint SMP_RemotePairRequestReply( 30119e95205Sopenharmony_ci uint16_t handle, uint8_t rejectReason, const BtAddr *localAddr, const BtAddr *peerAddr, const SMP_PairParam *param); 30219e95205Sopenharmony_ci 30319e95205Sopenharmony_ci/** 30419e95205Sopenharmony_ci * @brief Reply to peer pairing response. 30519e95205Sopenharmony_ci * 30619e95205Sopenharmony_ci * @param handle ACL Connection Handle. 30719e95205Sopenharmony_ci * @param accept Accept or reject. 30819e95205Sopenharmony_ci * @param rejectReason Reject Reason. 30919e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful; returns others if the operation fails. 31019e95205Sopenharmony_ci */ 31119e95205Sopenharmony_ciint SMP_RemotePairResponseReply(uint16_t handle, bool accept, uint8_t rejectReason); 31219e95205Sopenharmony_ci 31319e95205Sopenharmony_ci/** 31419e95205Sopenharmony_ci * @brief Reply peer security request. 31519e95205Sopenharmony_ci * 31619e95205Sopenharmony_ci * @param handle ACL Connection Handle. 31719e95205Sopenharmony_ci * @param accept Accept or reject. 31819e95205Sopenharmony_ci * @param rejectReason Reject reason. 31919e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful; returns others if the operation fails. 32019e95205Sopenharmony_ci */ 32119e95205Sopenharmony_ciint SMP_RemoteSecurityRequestReply(uint16_t handle, bool accept, uint8_t rejectReason); 32219e95205Sopenharmony_ci 32319e95205Sopenharmony_ci/** 32419e95205Sopenharmony_ci * @brief Reply to remote encryption request. 32519e95205Sopenharmony_ci * 32619e95205Sopenharmony_ci * @param handle ACL Connection Handle. 32719e95205Sopenharmony_ci * @param accept Accept or reject. 32819e95205Sopenharmony_ci * @param key Local long term key. 32919e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful; returns others if the operation fails. 33019e95205Sopenharmony_ci */ 33119e95205Sopenharmony_ciint SMP_LongTermKeyRequestReply(uint16_t handle, bool accept, const uint8_t *key); 33219e95205Sopenharmony_ci 33319e95205Sopenharmony_ci/** 33419e95205Sopenharmony_ci * @brief Proactively cancel pairing. 33519e95205Sopenharmony_ci * 33619e95205Sopenharmony_ci * @param handle ACL Connection Handle. 33719e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful; returns others if the operation fails. 33819e95205Sopenharmony_ci */ 33919e95205Sopenharmony_ciint SMP_CancelPair(uint16_t handle); 34019e95205Sopenharmony_ci 34119e95205Sopenharmony_ci/** 34219e95205Sopenharmony_ci * @brief Register callback functions. 34319e95205Sopenharmony_ci * 34419e95205Sopenharmony_ci * @param cb Point to <b>SMP_Callback_t</b> struct, the struct must be available before calling to 34519e95205Sopenharmony_ci * <b>SMP_UnregisterCallback</b>. 34619e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful; returns others if the operation fails. 34719e95205Sopenharmony_ci */ 34819e95205Sopenharmony_ciint SMP_RegisterCallback(const SMP_Callback_t *cb); 34919e95205Sopenharmony_ci 35019e95205Sopenharmony_ci/** 35119e95205Sopenharmony_ci * @brief Unregister callback functions. 35219e95205Sopenharmony_ci * 35319e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful; returns others if the operation fails. 35419e95205Sopenharmony_ci */ 35519e95205Sopenharmony_ciint SMP_UnregisterCallback(); 35619e95205Sopenharmony_ci 35719e95205Sopenharmony_ci/** 35819e95205Sopenharmony_ci * @brief Generate out of band data. 35919e95205Sopenharmony_ci * 36019e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful; returns others if the operation fails. 36119e95205Sopenharmony_ci */ 36219e95205Sopenharmony_ciint SMP_GenerateScOobData(); 36319e95205Sopenharmony_ci 36419e95205Sopenharmony_ci#ifdef __cplusplus 36519e95205Sopenharmony_ci} 36619e95205Sopenharmony_ci#endif 36719e95205Sopenharmony_ci 36819e95205Sopenharmony_ci#endif