diff options
author | vnugent <public@vaughnnugent.com> | 2024-06-11 15:44:28 -0400 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2024-06-11 15:44:28 -0400 |
commit | 461dd71069d0c0250752ac1256160605c33a6243 (patch) | |
tree | e854475ff9476c96a8257af0373c0bb064eeced8 /include/noscrypt.h | |
parent | a74f96251bcc81fb2c94fe75dd6f8043fd35fe0b (diff) |
feat!: #4 Close #4. Add public nip04 support to api
Diffstat (limited to 'include/noscrypt.h')
-rw-r--r-- | include/noscrypt.h | 72 |
1 files changed, 69 insertions, 3 deletions
diff --git a/include/noscrypt.h b/include/noscrypt.h index cdc74fe..f408dfc 100644 --- a/include/noscrypt.h +++ b/include/noscrypt.h @@ -77,7 +77,8 @@ extern "C" { #define NC_HMAC_KEY_SIZE 0x20 #define NC_ENCRYPTION_MAC_SIZE 0x20 #define NC_MESSAGE_KEY_SIZE NIP44_MESSAGE_KEY_SIZE -#define NC_NIP04_AES_IV_SIZE 0x10 /* AES IV size is 16 bytes (block size) */ +#define NC_NIP04_AES_IV_SIZE 0x10 /* AES IV size is 16 bytes (aka cipher block size) */ +#define NC_NIP04_AES_KEY_SIZE 0x20 /* AES 256 key size */ /* * From spec @@ -112,6 +113,20 @@ extern "C" { #define E_VERSION_NOT_SUPPORTED -6 +/* +* ENCRYPTION ALTERATION PROPERTEIS +* +* Codes for assigning values to an NCEncryptionArgs +* structure. +*/ + +#define NC_ENC_SET_VERSION 0x01 +#define NC_ENC_SET_NIP44_NONCE 0x02 +#define NC_ENC_SET_NIP44_MAC_KEY 0x03 +#define NC_ENC_SET_NIP04_KEY 0x04 +#define NC_ENC_SET_NIP04_IV 0x05 + + /* A compressed resul/return value, negative values are failure, 0 is success and positive values are defined by the operation. @@ -149,11 +164,11 @@ data buffers and required nonce used for the stream cipher. typedef struct nc_encryption_struct { /* The nonce used for the stream cipher. */ - const uint8_t* nonce32; + const uint8_t* nonceData; /* Writes the hmac key to the buffer during encryption events. Set to NULL on decryption */ - uint8_t* hmacKeyOut32; + uint8_t* keyData; /* The input data buffer to encrypt/decrypt */ const uint8_t* inputData; @@ -578,6 +593,57 @@ NC_EXPORT NCResult NCComputeMac( uint8_t hmacOut[NC_ENCRYPTION_MAC_SIZE] ); + +/* +* A special function that configures custom properties on +* the NCEncryptionArgs structure for a given operation. +* @param args A pointer to the encryption arguments structure +* @param property The ID property to set +* @param value The value to set the property to as a 32-bit integer +* @return NC_SUCCESS if the operation was successful, otherwise an error code. Use NCParseErrorCode to +* the error code and positional argument that caused the error. +*/ +NC_EXPORT NCResult NCSetEncryptionProperty( + NCEncryptionArgs* args, + uint32_t property, + uint32_t value +); + +/* +* A special function that configures custom properties on +* the NCEncryptionArgs structure for a given operation. +* +* @param args A pointer to the encryption arguments structure +* @param property The ID property to set +* @param value The value to set the property to as a byte buffer +* @param valueLen The length of the value buffer +* @return NC_SUCCESS if the operation was successful, otherwise an error code. Use NCParseErrorCode to +* the error code and positional argument that caused the error. +*/ +NC_EXPORT NCResult NCSetEncryptionPropertyEx( + NCEncryptionArgs* args, + uint32_t property, + uint8_t* value, + uint32_t valueLen +); + +/* +* Sets the encryption data buffers for the encryption/decryption +* operation. +* @param args A pointer to the encryption arguments structure +* @param input The input data buffer +* @param output The output data buffer +* @param dataSize The size of the data buffers +* @return NC_SUCCESS if the operation was successful, otherwise an error code. Use NCParseErrorCode to +* the error code and positional argument that caused the error. +*/ +NC_EXPORT NCResult NCSetEncryptionData( + NCEncryptionArgs* args, + const uint8_t* input, + uint8_t* output, + uint32_t dataSize +); + #ifdef __cplusplus } #endif /* __cplusplus */ |