-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
pal_rsa.h
100 lines (77 loc) · 3.75 KB
/
pal_rsa.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#pragma once
#include "pal_digest.h"
#include "pal_seckey.h"
#include "pal_compiler.h"
#include <Security/Security.h>
/*
Generate a new RSA keypair with the specified key size, in bits.
Follows pal_seckey return conventions.
*/
PALEXPORT int32_t AppleCryptoNative_RsaGenerateKey(int32_t keySizeBits,
SecKeyRef* pPublicKey,
SecKeyRef* pPrivateKey,
CFErrorRef* pErrorOut);
/*
Decrypt the contents of pbData using the provided privateKey under OAEP padding.
Follows pal_seckey return conventions.
*/
PALEXPORT int32_t AppleCryptoNative_RsaDecryptOaep(SecKeyRef privateKey,
uint8_t* pbData,
int32_t cbData,
PAL_HashAlgorithm mfgAlgorithm,
CFDataRef* pDecryptedOut,
CFErrorRef* pErrorOut);
/*
Decrypt the contents of pbData using the provided privateKey without validating or removing padding.
Follows pal_seckey return conventions.
*/
PALEXPORT int32_t AppleCryptoNative_RsaDecryptRaw(
SecKeyRef privateKey, uint8_t* pbData, int32_t cbData, CFDataRef* pDecryptedOut, CFErrorRef* pErrorOut);
/*
Decrypt the contents of pbData using the provided privateKey under PKCS#1 padding.
Follows pal_seckey return conventions.
*/
PALEXPORT int32_t AppleCryptoNative_RsaDecryptPkcs(
SecKeyRef privateKey, uint8_t* pbData, int32_t cbData, CFDataRef* pDecryptedOut, CFErrorRef* pErrorOut);
/*
Encrypt pbData for the provided publicKey using OAEP padding.
Follows pal_seckey return conventions.
*/
PALEXPORT int32_t AppleCryptoNative_RsaEncryptOaep(SecKeyRef publicKey,
uint8_t* pbData,
int32_t cbData,
PAL_HashAlgorithm mgfAlgorithm,
CFDataRef* pEncryptedOut,
CFErrorRef* pErrorOut);
/*
Encrypt pbData for the provided publicKey using PKCS#1 padding.
Follows pal_seckey return conventions.
*/
PALEXPORT int32_t AppleCryptoNative_RsaEncryptPkcs(
SecKeyRef publicKey, uint8_t* pbData, int32_t cbData, CFDataRef* pEncryptedOut, CFErrorRef* pErrorOut);
/*
Apply an RSA private key to a signing operation on data which was already padded.
Follows pal_seckey return conventions.
*/
PALEXPORT int32_t AppleCryptoNative_RsaSignaturePrimitive(
SecKeyRef privateKey, uint8_t* pbData, int32_t cbData, CFDataRef* pDataOut, CFErrorRef* pErrorOut);
/*
Apply an RSA private key to an encryption operation to emit data which is still padded.
Follows pal_seckey return conventions.
*/
PALEXPORT int32_t AppleCryptoNative_RsaDecryptionPrimitive(
SecKeyRef privateKey, uint8_t* pbData, int32_t cbData, CFDataRef* pDataOut, CFErrorRef* pErrorOut);
/*
Apply an RSA public key to an encryption operation on data which was already padded.
Follows pal_seckey return conventions.
*/
PALEXPORT int32_t AppleCryptoNative_RsaEncryptionPrimitive(
SecKeyRef publicKey, uint8_t* pbData, int32_t cbData, CFDataRef* pDataOut, CFErrorRef* pErrorOut);
/*
Apply an RSA public key to a signing operation to emit data which is still padded.
Follows pal_seckey return conventions.
*/
PALEXPORT int32_t AppleCryptoNative_RsaVerificationPrimitive(
SecKeyRef publicKey, uint8_t* pbData, int32_t cbData, CFDataRef* pDataOut, CFErrorRef* pErrorOut);