| 1 |
#ifndef AWS_CAL_RSA_H |
| 2 |
#define AWS_CAL_RSA_H |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#include <aws/cal/cal.h> |
| 8 |
#include <aws/common/byte_buf.h> |
| 9 |
|
| 10 |
AWS_PUSH_SANE_WARNING_LEVEL |
| 11 |
|
| 12 |
struct aws_rsa_key_pair; |
| 13 |
|
| 14 |
enum aws_rsa_encryption_algorithm { |
| 15 |
AWS_CAL_RSA_ENCRYPTION_PKCS1_5, |
| 16 |
AWS_CAL_RSA_ENCRYPTION_OAEP_SHA256, |
| 17 |
AWS_CAL_RSA_ENCRYPTION_OAEP_SHA512, |
| 18 |
}; |
| 19 |
|
| 20 |
enum aws_rsa_signature_algorithm { |
| 21 |
AWS_CAL_RSA_SIGNATURE_PKCS1_5_SHA256, |
| 22 |
AWS_CAL_RSA_SIGNATURE_PKCS1_5_SHA1, |
| 23 |
AWS_CAL_RSA_SIGNATURE_PSS_SHA256, |
| 24 |
}; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
enum { |
| 32 |
AWS_CAL_RSA_MIN_SUPPORTED_KEY_SIZE_IN_BITS = 1024, |
| 33 |
AWS_CAL_RSA_MAX_SUPPORTED_KEY_SIZE_IN_BITS = 4096, |
| 34 |
}; |
| 35 |
|
| 36 |
AWS_EXTERN_C_BEGIN |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
AWS_CAL_API struct aws_rsa_key_pair *aws_rsa_key_pair_new_from_public_key_pkcs1( |
| 44 |
struct aws_allocator *allocator, |
| 45 |
struct aws_byte_cursor key); |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
AWS_CAL_API struct aws_rsa_key_pair *aws_rsa_key_pair_new_from_private_key_pkcs1( |
| 53 |
struct aws_allocator *allocator, |
| 54 |
struct aws_byte_cursor key); |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
AWS_CAL_API struct aws_rsa_key_pair *aws_rsa_key_pair_new_from_private_key_pkcs8( |
| 62 |
struct aws_allocator *allocator, |
| 63 |
struct aws_byte_cursor key); |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
AWS_CAL_API struct aws_rsa_key_pair *aws_rsa_key_pair_acquire(struct aws_rsa_key_pair *key_pair); |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
AWS_CAL_API struct aws_rsa_key_pair *aws_rsa_key_pair_release(struct aws_rsa_key_pair *key_pair); |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
AWS_CAL_API size_t aws_rsa_key_pair_max_encrypt_plaintext_size( |
| 82 |
const struct aws_rsa_key_pair *key_pair, |
| 83 |
enum aws_rsa_encryption_algorithm algorithm); |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
AWS_CAL_API int aws_rsa_key_pair_encrypt( |
| 91 |
const struct aws_rsa_key_pair *key_pair, |
| 92 |
enum aws_rsa_encryption_algorithm algorithm, |
| 93 |
struct aws_byte_cursor plaintext, |
| 94 |
struct aws_byte_buf *out); |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
AWS_CAL_API int aws_rsa_key_pair_decrypt( |
| 102 |
const struct aws_rsa_key_pair *key_pair, |
| 103 |
enum aws_rsa_encryption_algorithm algorithm, |
| 104 |
struct aws_byte_cursor ciphertext, |
| 105 |
struct aws_byte_buf *out); |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
AWS_CAL_API size_t aws_rsa_key_pair_block_length(const struct aws_rsa_key_pair *key_pair); |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
AWS_CAL_API int aws_rsa_key_pair_sign_message( |
| 120 |
const struct aws_rsa_key_pair *key_pair, |
| 121 |
enum aws_rsa_signature_algorithm algorithm, |
| 122 |
struct aws_byte_cursor digest, |
| 123 |
struct aws_byte_buf *out); |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
AWS_CAL_API int aws_rsa_key_pair_verify_signature( |
| 135 |
const struct aws_rsa_key_pair *key_pair, |
| 136 |
enum aws_rsa_signature_algorithm algorithm, |
| 137 |
struct aws_byte_cursor digest, |
| 138 |
struct aws_byte_cursor signature); |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
AWS_CAL_API size_t aws_rsa_key_pair_signature_length(const struct aws_rsa_key_pair *key_pair); |
| 144 |
|
| 145 |
enum aws_rsa_key_export_format { |
| 146 |
AWS_CAL_RSA_KEY_EXPORT_PKCS1, |
| 147 |
}; |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
AWS_CAL_API int aws_rsa_key_pair_get_public_key( |
| 156 |
const struct aws_rsa_key_pair *key_pair, |
| 157 |
enum aws_rsa_key_export_format format, |
| 158 |
struct aws_byte_buf *out); |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
AWS_CAL_API int aws_rsa_key_pair_get_private_key( |
| 167 |
const struct aws_rsa_key_pair *key_pair, |
| 168 |
enum aws_rsa_key_export_format format, |
| 169 |
struct aws_byte_buf *out); |
| 170 |
|
| 171 |
AWS_EXTERN_C_END |
| 172 |
|
| 173 |
AWS_POP_SANE_WARNING_LEVEL |
| 174 |
|
| 175 |
#endif |