-
Notifications
You must be signed in to change notification settings - Fork 321
Expand file tree
/
Copy pathBRCryptoCipher.h
More file actions
80 lines (64 loc) Β· 2.6 KB
/
BRCryptoCipher.h
File metadata and controls
80 lines (64 loc) Β· 2.6 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
//
// BRCryptoCipher.h
// BRCore
//
// Created by Michael Carrara on 9/23/19.
// Copyright Β© 2019 Breadwinner AG. All rights reserved.
//
// See the LICENSE file at the project root for license information.
// See the CONTRIBUTORS file at the project root for a list of contributors.
#ifndef BRCryptoCipher_h
#define BRCryptoCipher_h
#include "BRCryptoBase.h"
#include "BRCryptoKey.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
CRYPTO_CIPHER_AESECB,
CRYPTO_CIPHER_CHACHA20_POLY1305,
CRYPTO_CIPHER_PIGEON
} BRCryptoCipherType;
typedef struct BRCryptoCipherRecord *BRCryptoCipher;
extern BRCryptoCipher
cryptoCipherCreateForAESECB(const uint8_t *key,
size_t keyLen);
extern BRCryptoCipher
cryptoCipherCreateForChacha20Poly1305(BRCryptoKey key,
const uint8_t *nonce, size_t nonceLen,
const uint8_t *authenticatedData, size_t authenticatedDataLen);
extern BRCryptoCipher
cryptoCipherCreateForPigeon(BRCryptoKey privKey,
BRCryptoKey pubKey,
const uint8_t *nonce, size_t nonceLen);
extern size_t
cryptoCipherEncryptLength (BRCryptoCipher cipher,
const uint8_t *plaintext,
size_t plaintextLen);
extern BRCryptoBoolean
cryptoCipherEncrypt (BRCryptoCipher cipher,
uint8_t *ciphertext,
size_t ciphertextLen,
const uint8_t *plaintext,
size_t plaintextLen);
extern size_t
cryptoCipherDecryptLength (BRCryptoCipher cipher,
const uint8_t *ciphertext,
size_t ciphertextLen);
extern BRCryptoBoolean
cryptoCipherDecrypt (BRCryptoCipher cipher,
uint8_t *plaintext,
size_t plaintextLen,
const uint8_t *ciphertext,
size_t ciphertextLen);
extern BRCryptoBoolean
cryptoCipherMigrateBRCoreKeyCiphertext (BRCryptoCipher cipher,
uint8_t *migratedCiphertext,
size_t migratedCiphertextLen,
const uint8_t *originalCiphertext,
size_t originalCiphertextLen);
DECLARE_CRYPTO_GIVE_TAKE (BRCryptoCipher, cryptoCipher);
#ifdef __cplusplus
}
#endif
#endif /* BRCryptoCipher_h */