DynXX-C
Loading...
Searching...
No Matches
Enumerations | Functions
Crypto.h File Reference
#include "Types.h"

Go to the source code of this file.

Enumerations

enum  DynXXCryptoRSAPadding {
  DynXXCryptoRSAPaddingPKCS1 = 1 , DynXXCryptoRSAPaddingSSLV23 = 2 , DynXXCryptoRSAPaddingNO = 3 , DynXXCryptoRSAPaddingPKCS1_OAEP = 4 ,
  DynXXCryptoRSAPaddingX931 = 5 , DynXXCryptoRSAPaddingPKCS1_PSS = 6
}
 RSA padding. More...
 

Functions

DYNXX_EXTERN_C_BEGIN const bytedynxx_crypto_rand (size_t len)
 Generate random bytes.
 
const bytedynxx_crypto_aes_encrypt (const byte *inBytes, size_t inLen, const byte *keyBytes, size_t keyLen, DYNXX_OUT size_t *outLen)
 AES Encrypt.
 
const bytedynxx_crypto_aes_decrypt (const byte *inBytes, size_t inLen, const byte *keyBytes, size_t keyLen, DYNXX_OUT size_t *outLen)
 AES Decrypt.
 
const bytedynxx_crypto_aes_gcm_encrypt (const byte *inBytes, size_t inLen, const byte *keyBytes, size_t keyLen, const byte *initVectorBytes, size_t initVectorLen, const byte *aadBytes, size_t aadLen, size_t tagBits, DYNXX_OUT size_t *outLen)
 AES GCM Encrypt.
 
const bytedynxx_crypto_aes_gcm_decrypt (const byte *inBytes, size_t inLen, const byte *keyBytes, size_t keyLen, const byte *initVectorBytes, size_t initVectorLen, const byte *aadBytes, size_t aadLen, size_t tagBits, DYNXX_OUT size_t *outLen)
 AES GCM Decrypt.
 
const char * dynxx_crypto_rsa_gen_key (const char *base64, bool isPublic)
 
const bytedynxx_crypto_rsa_encrypt (const byte *inBytes, size_t inLen, const byte *keyBytes, size_t keyLen, DynXXCryptoRSAPadding padding, DYNXX_OUT size_t *outLen)
 RSA Encrypt.
 
const bytedynxx_crypto_rsa_decrypt (const byte *inBytes, size_t inLen, const byte *keyBytes, size_t keyLen, DynXXCryptoRSAPadding padding, DYNXX_OUT size_t *outLen)
 RSA Decrypt.
 
const bytedynxx_crypto_hash_md5 (const byte *inBytes, size_t inLen, DYNXX_OUT size_t *outLen)
 MD5 hash.
 
const bytedynxx_crypto_hash_sha1 (const byte *inBytes, size_t inLen, DYNXX_OUT size_t *outLen)
 SHA1.
 
const bytedynxx_crypto_hash_sha256 (const byte *inBytes, size_t inLen, DYNXX_OUT size_t *outLen)
 SHA256.
 
const bytedynxx_crypto_base64_encode (const byte *inBytes, size_t inLen, bool noNewLines, DYNXX_OUT size_t *outLen)
 Base64 encode.
 
const bytedynxx_crypto_base64_decode (const byte *inBytes, size_t inLen, bool noNewLines, DYNXX_OUT size_t *outLen)
 Base64 decode.
 

Enumeration Type Documentation

◆ DynXXCryptoRSAPadding

RSA padding.

Enumerator
DynXXCryptoRSAPaddingPKCS1 
DynXXCryptoRSAPaddingSSLV23 
DynXXCryptoRSAPaddingNO 
DynXXCryptoRSAPaddingPKCS1_OAEP 
DynXXCryptoRSAPaddingX931 
DynXXCryptoRSAPaddingPKCS1_PSS 

Function Documentation

◆ dynxx_crypto_aes_decrypt()

const byte * dynxx_crypto_aes_decrypt ( const byte inBytes,
size_t  inLen,
const byte keyBytes,
size_t  keyLen,
DYNXX_OUT size_t *  outLen 
)

AES Decrypt.

Parameters
inBytesinput bytes data
inLeninput bytes length
keyByteskey bytes data
keyLenkey bytes length(MUST BE 16/24/32!!)
outLena pointer to read output bytes length
Returns
output bytes data(ALIGNED ON A 16 BYTE BOUNDARY!!)

◆ dynxx_crypto_aes_encrypt()

const byte * dynxx_crypto_aes_encrypt ( const byte inBytes,
size_t  inLen,
const byte keyBytes,
size_t  keyLen,
DYNXX_OUT size_t *  outLen 
)

AES Encrypt.

Parameters
inBytesinput bytes data
inLeninput bytes length
keyByteskey bytes data
keyLenkey bytes length(MUST BE 16/24/32!!)
outLena pointer to read output bytes length
Returns
output bytes data(ALIGNED ON A 16 BYTE BOUNDARY!!)

◆ dynxx_crypto_aes_gcm_decrypt()

const byte * dynxx_crypto_aes_gcm_decrypt ( const byte inBytes,
size_t  inLen,
const byte keyBytes,
size_t  keyLen,
const byte initVectorBytes,
size_t  initVectorLen,
const byte aadBytes,
size_t  aadLen,
size_t  tagBits,
DYNXX_OUT size_t *  outLen 
)

AES GCM Decrypt.

Parameters
inBytesbytes data to be decrypt(with a tag on tail)
inLenbytes length to be decrypt(include the tag)
keyByteskey bytes data
keyLenkey bytes length(MUST BE 16/24/32!!)
initVectorBytesinitVector bytes data
initVectorLeninitVector bytes length(MUST BE 12!!)
aadBytesAdditional Authentication Data (AAD) bytes(Can be nullptr
aadLenAdditional Authentication Data (AAD) length(Must <= 16)
tagBitstag bits length(MUST BE 96/104/112/120/128!!)
outLenoutput bytes length(Not include the tag)
Returns
output bytes data(No tag on tail)

◆ dynxx_crypto_aes_gcm_encrypt()

const byte * dynxx_crypto_aes_gcm_encrypt ( const byte inBytes,
size_t  inLen,
const byte keyBytes,
size_t  keyLen,
const byte initVectorBytes,
size_t  initVectorLen,
const byte aadBytes,
size_t  aadLen,
size_t  tagBits,
DYNXX_OUT size_t *  outLen 
)

AES GCM Encrypt.

Parameters
inBytesbytes data to be encrypt
inLenbytes length to be encrypt
keyByteskey bytes data
keyLenkey bytes length(MUST BE 16/24/32!!)
initVectorBytesinitVector bytes data
initVectorLeninitVector bytes length(MUST BE 12!!)
tagBitstag bits length(MUST BE 96/104/112/120/128!!)
aadBytesAdditional Authentication Data (AAD) bytes(Can be nullptr
aadLenAdditional Authentication Data (AAD) length(Must <= 16)
outLenoutput bytes length(include the tag)
Returns
output bytes data(With a tag on tail)

◆ dynxx_crypto_base64_decode()

const byte * dynxx_crypto_base64_decode ( const byte inBytes,
size_t  inLen,
bool  noNewLines,
DYNXX_OUT size_t *  outLen 
)

Base64 decode.

Parameters
inBytesinput bytes data
inLeninput bytes length
noNewLineswhether to add newlines
outLena pointer to read output bytes length
Returns
output bytes data

◆ dynxx_crypto_base64_encode()

const byte * dynxx_crypto_base64_encode ( const byte inBytes,
size_t  inLen,
bool  noNewLines,
DYNXX_OUT size_t *  outLen 
)

Base64 encode.

Parameters
inBytesinput bytes data
inLeninput bytes length
noNewLineswhether to add newlines
outLena pointer to read output bytes length
Returns
output bytes data

◆ dynxx_crypto_hash_md5()

const byte * dynxx_crypto_hash_md5 ( const byte inBytes,
size_t  inLen,
DYNXX_OUT size_t *  outLen 
)

MD5 hash.

Parameters
inBytesinput bytes data
inLeninput bytes length
outLena pointer to read output bytes length
Returns
output bytes data

◆ dynxx_crypto_hash_sha1()

const byte * dynxx_crypto_hash_sha1 ( const byte inBytes,
size_t  inLen,
DYNXX_OUT size_t *  outLen 
)

SHA1.

Parameters
inBytesinput bytes data
inLeninput bytes length
outLena pointer to read output bytes length
Returns
output bytes data

◆ dynxx_crypto_hash_sha256()

const byte * dynxx_crypto_hash_sha256 ( const byte inBytes,
size_t  inLen,
DYNXX_OUT size_t *  outLen 
)

SHA256.

Parameters
inBytesinput bytes data
inLeninput bytes length
outLena pointer to read output bytes length
Returns
output bytes data

◆ dynxx_crypto_rand()

DYNXX_EXTERN_C_BEGIN const byte * dynxx_crypto_rand ( size_t  len)

Generate random bytes.

Parameters
lenbytes length
Returns
output bytes

◆ dynxx_crypto_rsa_decrypt()

const byte * dynxx_crypto_rsa_decrypt ( const byte inBytes,
size_t  inLen,
const byte keyBytes,
size_t  keyLen,
DynXXCryptoRSAPadding  padding,
DYNXX_OUT size_t *  outLen 
)

RSA Decrypt.

Parameters
inBytesinput bytes data
inLeninput bytes length
keyBytesPrivate-Key bytes data
keyLenPrivate-Key bytes length
paddingsee DynXXCryptoRSAPadding
outLena pointer to read output bytes length
Returns
output bytes data

◆ dynxx_crypto_rsa_encrypt()

const byte * dynxx_crypto_rsa_encrypt ( const byte inBytes,
size_t  inLen,
const byte keyBytes,
size_t  keyLen,
DynXXCryptoRSAPadding  padding,
DYNXX_OUT size_t *  outLen 
)

RSA Encrypt.

Parameters
inBytesinput bytes data
inLeninput bytes length
keyBytesPublic-Key bytes data
keyLenPublic-Key bytes length
paddingsee DynXXCryptoRSAPadding
outLena pointer to read output bytes length
Returns
output bytes data

◆ dynxx_crypto_rsa_gen_key()

const char * dynxx_crypto_rsa_gen_key ( const char *  base64,
bool  isPublic 
)