AWS SDK for C++  1.8.76
AWS SDK for C++
Typedefs | Enumerations | Functions
CommonCryptorSPI.h File Reference
#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 Documentation

◆ CCParameter

typedef uint32_t CCParameter

Definition at line 444 of file CommonCryptorSPI.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ccDefaultPadding 

Definition at line 59 of file CommonCryptorSPI.h.

◆ anonymous enum

anonymous enum
Enumerator
kCCAlgorithmAES128NoHardware 
kCCAlgorithmAES128WithHardware 

Definition at line 64 of file CommonCryptorSPI.h.

◆ anonymous enum

anonymous enum
Enumerator
kCCModeGCM 
kCCModeCCM 

Definition at line 72 of file CommonCryptorSPI.h.

◆ anonymous enum

anonymous enum
Enumerator
ccCBCCTS1 
ccCBCCTS2 
ccCBCCTS3 

Definition at line 80 of file CommonCryptorSPI.h.

◆ anonymous enum

anonymous enum
Enumerator
kCCBoth 

Definition at line 89 of file CommonCryptorSPI.h.

◆ anonymous enum

anonymous enum
Enumerator
kCCParameterIV 
kCCParameterAuthData 
kCCMacSize 
kCCDataSize 
kCCParameterAuthTag 

Definition at line 407 of file CommonCryptorSPI.h.

Function Documentation

◆ CC_RC4()

void CC_RC4 ( void *  ctx,
unsigned long  len,
const unsigned char *  indata,
unsigned char *  outdata 
)

◆ CC_RC4_set_key()

void CC_RC4_set_key ( void *  ctx,
int  len,
const unsigned char *  data 
)

◆ CCCryptorAddParameter()

CCCryptorStatus CCCryptorAddParameter ( CCCryptorRef  cryptorRef,
CCParameter  parameter,
const void *  data,
size_t  dataSize 
)

◆ CCCryptorCreateFromDataWithMode()

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 
)

◆ CCCryptorDecryptDataBlock()

CCCryptorStatus CCCryptorDecryptDataBlock ( CCCryptorRef  cryptorRef,
const void *  iv,
const void *  dataIn,
size_t  dataInLength,
void *  dataOut 
)

◆ CCCryptorEncryptDataBlock()

CCCryptorStatus CCCryptorEncryptDataBlock ( CCCryptorRef  cryptorRef,
const void *  iv,
const void *  dataIn,
size_t  dataInLength,
void *  dataOut 
)

◆ CCCryptorGCM()

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 
)

◆ CCCryptorGCMAddAAD()

CCCryptorStatus CCCryptorGCMAddAAD ( CCCryptorRef  cryptorRef,
const void *  aData,
size_t  aDataLen 
)

◆ CCCryptorGCMAddADD()

CCCryptorStatus CCCryptorGCMAddADD ( CCCryptorRef  cryptorRef,
const void *  aData,
size_t  aDataLen 
)

◆ CCCryptorGCMAddIV()

CCCryptorStatus CCCryptorGCMAddIV ( CCCryptorRef  cryptorRef,
const void *  iv,
size_t  ivLen 
)

◆ CCCryptorGCMDecrypt()

CCCryptorStatus CCCryptorGCMDecrypt ( CCCryptorRef  cryptorRef,
const void *  dataIn,
size_t  dataInLength,
void *  dataOut 
)

◆ CCCryptorGCMEncrypt()

CCCryptorStatus CCCryptorGCMEncrypt ( CCCryptorRef  cryptorRef,
const void *  dataIn,
size_t  dataInLength,
void *  dataOut 
)

◆ CCCryptorGCMFinal()

CCCryptorStatus CCCryptorGCMFinal ( CCCryptorRef  cryptorRef,
void *  tagOut,
size_t *  tagLength 
)

◆ CCCryptorGCMFinalize()

CCCryptorStatus CCCryptorGCMFinalize ( CCCryptorRef  cryptorRef,
void *  tag,
size_t  tagLength 
)

◆ CCCryptorGCMOneshotDecrypt()

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 
)

CCCryptorGCMOneshotDecrypt Decrypts using AES-GCM, compares the computed tag of the decrypted message to the input tag and returns error is authentication fails.

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.

◆ CCCryptorGCMOneshotEncrypt()

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 
)

CCCryptorGCMOneshotDecrypt Encrypts using AES-GCM and outputs encrypted data and an authentication tag

Parameters
algIt can only be kCCAlgorithmAES
keyKey for the underlying AES blockcipher. It must be 16 bytes. *****
keyLengthLength of the key in bytes
ivInitialization vector, must be at least 12 bytes
ivLengthLength of the IV in bytes
aDataAdditional data to authenticate. It can be NULL, if there is no additional data to be authenticated.
aDataLengthLength of the additional data in bytes. It can be zero.
dataInInput plaintext
dataInLengthLength of the input plaintext data in bytes
cipherOutOutput ciphertext
tagLengthLength of the output authentication tag in bytes. It is minimum 8 bytes and maximum 16 bytes.
tagOutthe output authentication tag
Returns
kccSuccess if successful.

It is a one-shot AESGCM encryption and in-place encryption is supported.

Warning
The key-IV pair must be unique per encryption. The IV must be nonzero in length.

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).

◆ CCCryptorGCMReset()

CCCryptorStatus CCCryptorGCMReset ( CCCryptorRef  cryptorRef)

◆ CCCryptorGCMSetIV()

CCCryptorStatus CCCryptorGCMSetIV ( CCCryptorRef  cryptorRef,
const void *  iv,
size_t  ivLen 
)

◆ CCCryptorGetIV()

CCCryptorStatus CCCryptorGetIV ( CCCryptorRef  cryptorRef,
void *  iv 
)

◆ CCCryptorGetParameter()

CCCryptorStatus CCCryptorGetParameter ( CCCryptorRef  cryptorRef,
CCParameter  parameter,
void *  data,
size_t *  dataSize 
)

◆ CCCryptorReset_binary_compatibility()

CCCryptorStatus CCCryptorReset_binary_compatibility ( CCCryptorRef  cryptorRef,
const void *  iv 
)

CCCryptorReset_binary_compatibility 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.

Returns
The only possible error is kCCParamError.

◆ ios() [1/6]

void ios ( 5.  0)

◆ ios() [2/6]

CCCryptorStatus ios ( 2.  0,
11.  0 
)

◆ ios() [3/6]

CCCryptorStatus ios ( 5.  0,
11.  0 
)

◆ ios() [4/6]

CCCryptorStatus ios ( 11.  0)

◆ ios() [5/6]

CCCryptorStatus ios ( 6.  0)

◆ ios() [6/6]

CCCryptorStatus ios ( 6.  0,
11.  0 
)

◆ macos()

CCCryptorStatus macos ( 10.  4,
10.  13 
)