AWS SDK for C++
1.11.77
AWS SDK for C++
|
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <os/availability.h>
#include <CommonCrypto/CommonCryptoError.h>
#include <CommonCrypto/CommonCryptor.h>
Go to the source code of this file.
Typedefs | |
typedef uint32_t | CCParameter |
Enumerations | |
enum | { ccDefaultPadding = 0 } |
enum | { kCCAlgorithmAES128NoHardware = 20 , kCCAlgorithmAES128WithHardware = 21 } |
enum | { kCCModeGCM = 11 , kCCModeCCM = 12 } |
enum | { ccCBCCTS1 = 10 , ccCBCCTS2 = 11 , ccCBCCTS3 = 12 } |
enum | { kCCBoth = 3 } |
enum | { kCCParameterIV , kCCParameterAuthData , kCCMacSize , kCCDataSize , kCCParameterAuthTag } |
Functions | |
CCCryptorStatus | CCCryptorCreateFromDataWithMode (CCOperation op, CCMode mode, CCAlgorithm alg, CCPadding padding, const void *iv, const void *key, size_t keyLength, const void *tweak, size_t tweakLength, int numRounds, CCModeOptions options, const void *data, size_t dataLength, CCCryptorRef *cryptorRef, size_t *dataUsed) API_AVAILABLE(macos(10.7) |
CCCryptorStatus | ios (5.0)) |
CCCryptorStatus | CCCryptorEncryptDataBlock (CCCryptorRef cryptorRef, const void *iv, const void *dataIn, size_t dataInLength, void *dataOut) API_AVAILABLE(macos(10.7) |
CCCryptorStatus | CCCryptorDecryptDataBlock (CCCryptorRef cryptorRef, const void *iv, const void *dataIn, size_t dataInLength, void *dataOut) API_AVAILABLE(macos(10.7) |
CCCryptorStatus | CCCryptorReset_binary_compatibility (CCCryptorRef cryptorRef, const void *iv) API_DEPRECATED_WITH_REPLACEMENT("CCCryptorReset" |
CCCryptorStatus | macos (10.4, 10.13) |
CCCryptorStatus | ios (2.0, 11.0)) |
CCCryptorStatus | CCCryptorGetIV (CCCryptorRef cryptorRef, void *iv) API_AVAILABLE(macos(10.7) |
CCCryptorStatus | CCCryptorGCMAddIV (CCCryptorRef cryptorRef, const void *iv, size_t ivLen) API_DEPRECATED_WITH_REPLACEMENT("CCCryptorGCMSetIV" |
CCCryptorStatus | ios (5.0, 11.0)) |
CCCryptorStatus | CCCryptorGCMSetIV (CCCryptorRef cryptorRef, const void *iv, size_t ivLen) API_AVAILABLE(macos(10.13) |
CCCryptorStatus | ios (11.0)) |
CCCryptorStatus | CCCryptorGCMAddAAD (CCCryptorRef cryptorRef, const void *aData, size_t aDataLen) API_AVAILABLE(macos(10.8) |
CCCryptorStatus | ios (6.0)) |
CCCryptorStatus | CCCryptorGCMAddADD (CCCryptorRef cryptorRef, const void *aData, size_t aDataLen) API_AVAILABLE(macos(10.8) |
CCCryptorStatus | CCCryptorGCMEncrypt (CCCryptorRef cryptorRef, const void *dataIn, size_t dataInLength, void *dataOut) API_AVAILABLE(macos(10.8) |
CCCryptorStatus | CCCryptorGCMDecrypt (CCCryptorRef cryptorRef, const void *dataIn, size_t dataInLength, void *dataOut) API_AVAILABLE(macos(10.8) |
CCCryptorStatus | CCCryptorGCMFinal (CCCryptorRef cryptorRef, void *tagOut, size_t *tagLength) API_DEPRECATED_WITH_REPLACEMENT("CCCryptorGCMFinalize" |
CCCryptorStatus | CCCryptorGCMFinalize (CCCryptorRef cryptorRef, void *tag, size_t tagLength) API_AVAILABLE(macos(10.13) |
CCCryptorStatus | CCCryptorGCMReset (CCCryptorRef cryptorRef) API_AVAILABLE(macos(10.8) |
CCCryptorStatus | CCCryptorGCM (CCOperation op, CCAlgorithm alg, const void *key, size_t keyLength, const void *iv, size_t ivLen, const void *aData, size_t aDataLen, const void *dataIn, size_t dataInLength, void *dataOut, void *tagOut, size_t *tagLength) API_DEPRECATED_WITH_REPLACEMENT("CCCryptorGCMOneshotEncrypt or CCCryptorGCMOneshotDecrypt" |
CCCryptorStatus | ios (6.0, 11.0)) |
CCCryptorStatus | CCCryptorGCMOneshotEncrypt (CCAlgorithm alg, const void *key, size_t keyLength, const void *iv, size_t ivLength, const void *aData, size_t aDataLength, const void *dataIn, size_t dataInLength, void *cipherOut, void *tagOut, size_t tagLength) __attribute__((__warn_unused_result__)) API_AVAILABLE(macos(10.13) |
CCCryptorStatus | CCCryptorGCMOneshotDecrypt (CCAlgorithm alg, const void *key, size_t keyLength, const void *iv, size_t ivLen, const void *aData, size_t aDataLen, const void *dataIn, size_t dataInLength, void *dataOut, const void *tagIn, size_t tagLength) __attribute__((__warn_unused_result__)) API_AVAILABLE(macos(10.13) |
void | CC_RC4_set_key (void *ctx, int len, const unsigned char *data) API_AVAILABLE(macos(10.4) |
void | CC_RC4 (void *ctx, unsigned long len, const unsigned char *indata, unsigned char *outdata) API_AVAILABLE(macos(10.4) |
CCCryptorStatus | CCCryptorAddParameter (CCCryptorRef cryptorRef, CCParameter parameter, const void *data, size_t dataSize) |
CCCryptorStatus | CCCryptorGetParameter (CCCryptorRef cryptorRef, CCParameter parameter, void *data, size_t *dataSize) |
typedef uint32_t CCParameter |
Definition at line 444 of file CommonCryptorSPI.h.
anonymous enum |
Enumerator | |
---|---|
ccDefaultPadding |
Definition at line 59 of file CommonCryptorSPI.h.
anonymous enum |
Enumerator | |
---|---|
kCCAlgorithmAES128NoHardware | |
kCCAlgorithmAES128WithHardware |
Definition at line 64 of file CommonCryptorSPI.h.
anonymous enum |
Enumerator | |
---|---|
kCCModeGCM | |
kCCModeCCM |
Definition at line 72 of file CommonCryptorSPI.h.
anonymous enum |
Enumerator | |
---|---|
ccCBCCTS1 | |
ccCBCCTS2 | |
ccCBCCTS3 |
Definition at line 80 of file CommonCryptorSPI.h.
anonymous enum |
Enumerator | |
---|---|
kCCBoth |
Definition at line 89 of file CommonCryptorSPI.h.
anonymous enum |
Enumerator | |
---|---|
kCCParameterIV | |
kCCParameterAuthData | |
kCCMacSize | |
kCCDataSize | |
kCCParameterAuthTag |
Definition at line 407 of file CommonCryptorSPI.h.
void CC_RC4 | ( | void * | ctx, |
unsigned long | len, | ||
const unsigned char * | indata, | ||
unsigned char * | outdata | ||
) |
void CC_RC4_set_key | ( | void * | ctx, |
int | len, | ||
const unsigned char * | data | ||
) |
CCCryptorStatus CCCryptorAddParameter | ( | CCCryptorRef | cryptorRef, |
CCParameter | parameter, | ||
const void * | data, | ||
size_t | dataSize | ||
) |
CCCryptorStatus CCCryptorCreateFromDataWithMode | ( | CCOperation | op, |
CCMode | mode, | ||
CCAlgorithm | alg, | ||
CCPadding | padding, | ||
const void * | iv, | ||
const void * | key, | ||
size_t | keyLength, | ||
const void * | tweak, | ||
size_t | tweakLength, | ||
int | numRounds, | ||
CCModeOptions | options, | ||
const void * | data, | ||
size_t | dataLength, | ||
CCCryptorRef * | cryptorRef, | ||
size_t * | dataUsed | ||
) |
CCCryptorStatus CCCryptorDecryptDataBlock | ( | CCCryptorRef | cryptorRef, |
const void * | iv, | ||
const void * | dataIn, | ||
size_t | dataInLength, | ||
void * | dataOut | ||
) |
CCCryptorStatus CCCryptorEncryptDataBlock | ( | CCCryptorRef | cryptorRef, |
const void * | iv, | ||
const void * | dataIn, | ||
size_t | dataInLength, | ||
void * | dataOut | ||
) |
CCCryptorStatus CCCryptorGCM | ( | CCOperation | op, |
CCAlgorithm | alg, | ||
const void * | key, | ||
size_t | keyLength, | ||
const void * | iv, | ||
size_t | ivLen, | ||
const void * | aData, | ||
size_t | aDataLen, | ||
const void * | dataIn, | ||
size_t | dataInLength, | ||
void * | dataOut, | ||
void * | tagOut, | ||
size_t * | tagLength | ||
) |
CCCryptorStatus CCCryptorGCMAddAAD | ( | CCCryptorRef | cryptorRef, |
const void * | aData, | ||
size_t | aDataLen | ||
) |
CCCryptorStatus CCCryptorGCMAddADD | ( | CCCryptorRef | cryptorRef, |
const void * | aData, | ||
size_t | aDataLen | ||
) |
CCCryptorStatus CCCryptorGCMAddIV | ( | CCCryptorRef | cryptorRef, |
const void * | iv, | ||
size_t | ivLen | ||
) |
CCCryptorStatus CCCryptorGCMDecrypt | ( | CCCryptorRef | cryptorRef, |
const void * | dataIn, | ||
size_t | dataInLength, | ||
void * | dataOut | ||
) |
CCCryptorStatus CCCryptorGCMEncrypt | ( | CCCryptorRef | cryptorRef, |
const void * | dataIn, | ||
size_t | dataInLength, | ||
void * | dataOut | ||
) |
CCCryptorStatus CCCryptorGCMFinal | ( | CCCryptorRef | cryptorRef, |
void * | tagOut, | ||
size_t * | tagLength | ||
) |
CCCryptorStatus CCCryptorGCMFinalize | ( | CCCryptorRef | cryptorRef, |
void * | tag, | ||
size_t | tagLength | ||
) |
CCCryptorStatus CCCryptorGCMOneshotDecrypt | ( | CCAlgorithm | alg, |
const void * | key, | ||
size_t | keyLength, | ||
const void * | iv, | ||
size_t | ivLen, | ||
const void * | aData, | ||
size_t | aDataLen, | ||
const void * | dataIn, | ||
size_t | dataInLength, | ||
void * | dataOut, | ||
const void * | tagIn, | ||
size_t | tagLength | ||
) |
@function CCCryptorGCMOneshotDecrypt @abstract Decrypts using AES-GCM, compares the computed tag of the decrypted message to the input tag and returns error is authentication fails.
@discussion CCCryptorGCMOneshotDecrypt() works similar to the CCCryptorGCMOneshotEncrypt(). CCCryptorGCMOneshotDecrypt() does not return the tag of the decrypted message. It compated the computed tag with inout tag and outputs error if authentication of the decrypted message fails.
CCCryptorStatus CCCryptorGCMOneshotEncrypt | ( | CCAlgorithm | alg, |
const void * | key, | ||
size_t | keyLength, | ||
const void * | iv, | ||
size_t | ivLength, | ||
const void * | aData, | ||
size_t | aDataLength, | ||
const void * | dataIn, | ||
size_t | dataInLength, | ||
void * | cipherOut, | ||
void * | tagOut, | ||
size_t | tagLength | ||
) |
@function CCCryptorGCMOneshotDecrypt @abstract Encrypts using AES-GCM and outputs encrypted data and an authentication tag
alg | It can only be kCCAlgorithmAES |
key | Key for the underlying AES blockcipher. It must be 16 bytes. ***** |
keyLength | Length of the key in bytes |
iv | Initialization vector, must be at least 12 bytes |
ivLength | Length of the IV in bytes |
aData | Additional data to authenticate. It can be NULL, if there is no additional data to be authenticated. |
aDataLength | Length of the additional data in bytes. It can be zero. |
dataIn | Input plaintext |
dataInLength | Length of the input plaintext data in bytes |
cipherOut | Output ciphertext |
tagLength | Length of the output authentication tag in bytes. It is minimum 8 bytes and maximum 16 bytes. |
tagOut | the output authentication tag |
@discussion It is a one-shot AESGCM encryption and in-place encryption is supported.
In stateful protocols, if each packet exposes a guaranteed-unique value, it is recommended to format this as a 12-byte value for use as the IV.
In stateless protocols, it is recommended to choose a 16-byte value using a cryptographically-secure pseudorandom number generator (e.g. ccrng
).
CCCryptorStatus CCCryptorGCMReset | ( | CCCryptorRef | cryptorRef | ) |
CCCryptorStatus CCCryptorGCMSetIV | ( | CCCryptorRef | cryptorRef, |
const void * | iv, | ||
size_t | ivLen | ||
) |
CCCryptorStatus CCCryptorGetIV | ( | CCCryptorRef | cryptorRef, |
void * | iv | ||
) |
CCCryptorStatus CCCryptorGetParameter | ( | CCCryptorRef | cryptorRef, |
CCParameter | parameter, | ||
void * | data, | ||
size_t * | dataSize | ||
) |
CCCryptorStatus CCCryptorReset_binary_compatibility | ( | CCCryptorRef | cryptorRef, |
const void * | iv | ||
) |
@function CCCryptorReset_binary_compatibility @abstract Do not call this function. Reinitializes an existing CCCryptorRef with a (possibly) new initialization vector. The CCCryptorRef's key is unchanged. Preserves compatibility for Sdks prior to macOS 10.13, iOS 11, watchOS 4 and tvOS 11. It is used internally in CommonCrypto. See CCCryptorReset for more information.
CCCryptorStatus ios | ( | 11. | 0 | ) |
CCCryptorStatus ios | ( | 2. | 0, |
11. | 0 | ||
) |
void ios | ( | 5. | 0 | ) |
CCCryptorStatus ios | ( | 5. | 0, |
11. | 0 | ||
) |
CCCryptorStatus ios | ( | 6. | 0 | ) |
CCCryptorStatus ios | ( | 6. | 0, |
11. | 0 | ||
) |
CCCryptorStatus macos | ( | 10. | 4, |
10. | 13 | ||
) |