-
Notifications
You must be signed in to change notification settings - Fork 232
/
Copy pathHAPIPSecurityProtocol.h
68 lines (57 loc) · 1.97 KB
/
HAPIPSecurityProtocol.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) 2015-2019 The HomeKit ADK Contributors
//
// Licensed under the Apache License, Version 2.0 (the “License”);
// you may not use this file except in compliance with the License.
// See [CONTRIBUTORS.md] for the list of HomeKit ADK project authors.
#ifndef HAP_IP_SECURITY_PROTOCOL_H
#define HAP_IP_SECURITY_PROTOCOL_H
#ifdef __cplusplus
extern "C" {
#endif
#include "HAP+Internal.h"
#if __has_feature(nullability)
#pragma clang assume_nonnull begin
#endif
/**
* Maximum frame length in the IP security protocol.
*/
#define kHAPIPSecurityProtocol_MaxFrameBytes ((size_t) 1024)
/**
* Computes the number of encrypted bytes given the number of plaintext bytes.
*
* @param numPlaintextBytes Number of plaintext bytes.
*
* @return Number of encrypted bytes given the number of plaintext bytes.
*/
HAP_RESULT_USE_CHECK
size_t HAPIPSecurityProtocolGetNumEncryptedBytes(size_t numPlaintextBytes);
/**
* Encrypts data to be sent over a HomeKit session.
*
* @param server Accessory server.
* @param session The session over which the data will be sent.
* @param buffer Plaintext data to be encrypted.
*/
void HAPIPSecurityProtocolEncryptData(HAPAccessoryServerRef* server, HAPSessionRef* session, HAPIPByteBuffer* buffer);
/**
* Decrypts data received over a HomeKit session.
*
* @param server Accessory server.
* @param session The session over which the data has been received.
* @param buffer Encrypted data to be decrypted.
*
* @return kHAPError_None If successful.
* @return kHAPError_InvalidData If the controller sent a malformed data, or decryption failed.
*/
HAP_RESULT_USE_CHECK
HAPError HAPIPSecurityProtocolDecryptData(
HAPAccessoryServerRef* server,
HAPSessionRef* session,
HAPIPByteBuffer* buffer);
#if __has_feature(nullability)
#pragma clang assume_nonnull end
#endif
#ifdef __cplusplus
}
#endif
#endif