Skip to content

Commit 1f59d7a

Browse files
authored
Update the plugins to the latest specification headers, and update to 64-bit integers. (#78)
1 parent 1fe2c12 commit 1f59d7a

File tree

6 files changed

+60
-60
lines changed

6 files changed

+60
-60
lines changed

src/encryptionPlugins/EncryptDataAES256CBCPlugin.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/**********************************************************************************
3-
© Copyright Senzing, Inc. 2020-2024
3+
© Copyright Senzing, Inc. 2020-2025
44
The source code for this program is not published or otherwise divested
55
of its trade secrets, irrespective of what has been deposited with the U.S.
66
Copyright Office.
@@ -82,7 +82,7 @@ void getPluginSignature(char* signature)
8282

8383

8484
/* Function used to initialize a plugin.
85-
* See the function prototype defintions for more information.
85+
* See the function prototype definitions for more information.
8686
*/
8787
G2_ENCRYPTION_PLUGIN_FUNCTION_INIT_PLUGIN
8888
{
@@ -130,7 +130,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_INIT_PLUGIN
130130

131131

132132
/* Function used to close a plugin.
133-
* See the function prototype defintions for more information.
133+
* See the function prototype definitions for more information.
134134
*/
135135
G2_ENCRYPTION_PLUGIN_FUNCTION_CLOSE_PLUGIN
136136
{
@@ -149,7 +149,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_CLOSE_PLUGIN
149149

150150

151151
/* Function used to retrieve the plugin signature.
152-
* See the function prototype defintions for more information.
152+
* See the function prototype definitions for more information.
153153
*/
154154
G2_ENCRYPTION_PLUGIN_FUNCTION_GET_SIGNATURE
155155
{
@@ -183,7 +183,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_GET_SIGNATURE
183183

184184

185185
/* Function used to validate the plugin signature compatibility.
186-
* See the function prototype defintions for more information.
186+
* See the function prototype definitions for more information.
187187
*/
188188
G2_ENCRYPTION_PLUGIN_FUNCTION_VALIDATE_SIGNATURE_COMPATIBILITY
189189
{
@@ -207,11 +207,11 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_VALIDATE_SIGNATURE_COMPATIBILITY
207207

208208
/* Function to do a simple encryption.
209209
*/
210-
int encrypt(unsigned char *plaintext, int plaintext_len, unsigned char *key, unsigned char *iv, unsigned char *ciphertext, struct ErrorInfoData* errorData)
210+
int64_t encrypt(unsigned char *plaintext, size_t plaintext_len, unsigned char *key, unsigned char *iv, unsigned char *ciphertext, struct ErrorInfoData* errorData)
211211
{
212212
EVP_CIPHER_CTX *ctx = NULL;
213213
int len = 0;
214-
int ciphertext_len = 0;
214+
size_t ciphertext_len = 0;
215215

216216
/* Create and initialise the context */
217217
if(!(ctx = EVP_CIPHER_CTX_new()))
@@ -264,11 +264,11 @@ int encrypt(unsigned char *plaintext, int plaintext_len, unsigned char *key, uns
264264

265265
/* Function to do a simple decryption.
266266
*/
267-
int decrypt(unsigned char *ciphertext, int ciphertext_len, unsigned char *key, unsigned char *iv, unsigned char *plaintext, struct ErrorInfoData* errorData)
267+
int64_t decrypt(unsigned char *ciphertext, size_t ciphertext_len, unsigned char *key, unsigned char *iv, unsigned char *plaintext, struct ErrorInfoData* errorData)
268268
{
269269
EVP_CIPHER_CTX *ctx = NULL;
270270
int len = 0;
271-
int plaintext_len = 0;
271+
size_t plaintext_len = 0;
272272

273273
/* Create and initialise the context */
274274
if(!(ctx = EVP_CIPHER_CTX_new()))
@@ -305,7 +305,7 @@ int decrypt(unsigned char *ciphertext, int ciphertext_len, unsigned char *key, u
305305
* Finalise the decryption. Further plaintext bytes may be written at
306306
* this stage.
307307
*/
308-
int retVal = EVP_DecryptFinal_ex(ctx, plaintext + len, &len);
308+
int64_t retVal = EVP_DecryptFinal_ex(ctx, plaintext + len, &len);
309309
if(1 != retVal)
310310
{
311311
handleErrors("Failed to finalize decryption",errorData);
@@ -321,7 +321,7 @@ int decrypt(unsigned char *ciphertext, int ciphertext_len, unsigned char *key, u
321321

322322

323323
/* Function used to encrypt a data value.
324-
* See the function prototype defintions for more information.
324+
* See the function prototype definitions for more information.
325325
*/
326326
G2_ENCRYPTION_PLUGIN_FUNCTION_ENCRYPT_DATA_FIELD
327327
{
@@ -331,7 +331,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_ENCRYPT_DATA_FIELD
331331
/* encrypt the data */
332332
const size_t bufferLength = inputSize + EVP_MAX_BLOCK_LENGTH;
333333
unsigned char* ciphertext = malloc(bufferLength * sizeof(char));
334-
int ciphertext_len = encrypt((unsigned char*)input,(int)inputSize,(unsigned char*)mEncryptionKey,(unsigned char*)mEncryptionIV,ciphertext,&encryptionErrorData);
334+
size_t ciphertext_len = encrypt((unsigned char*)input,(int64_t)inputSize,(unsigned char*)mEncryptionKey,(unsigned char*)mEncryptionIV,ciphertext,&encryptionErrorData);
335335
if (!(encryptionErrorData.mErrorOccurred))
336336
{
337337
if (((size_t) ciphertext_len) < maxResultSize)
@@ -353,7 +353,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_ENCRYPT_DATA_FIELD
353353

354354

355355
/* Function used to decrypt a data value.
356-
* See the function prototype defintions for more information.
356+
* See the function prototype definitions for more information.
357357
*/
358358
G2_ENCRYPTION_PLUGIN_FUNCTION_DECRYPT_DATA_FIELD
359359
{
@@ -363,7 +363,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_DECRYPT_DATA_FIELD
363363
/* decrypt the data */
364364
const size_t bufferLength = inputSize + EVP_MAX_BLOCK_LENGTH;
365365
unsigned char* decryptedtext = malloc(bufferLength * sizeof(char));
366-
int decryptedtext_len = decrypt((unsigned char*)input,(int)inputSize,(unsigned char*)mEncryptionKey,(unsigned char*)mEncryptionIV,decryptedtext,&decryptionErrorData);
366+
size_t decryptedtext_len = decrypt((unsigned char*)input,(int64_t)inputSize,(unsigned char*)mEncryptionKey,(unsigned char*)mEncryptionIV,decryptedtext,&decryptionErrorData);
367367
if (!(decryptionErrorData.mErrorOccurred))
368368
{
369369
if (((size_t) decryptedtext_len) < maxResultSize)
@@ -385,7 +385,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_DECRYPT_DATA_FIELD
385385

386386

387387
/* Function used to encrypt a data value (deterministic methods.)
388-
* See the function prototype defintions for more information.
388+
* See the function prototype definitions for more information.
389389
*/
390390
G2_ENCRYPTION_PLUGIN_FUNCTION_ENCRYPT_DATA_FIELD_DETERMINISTIC
391391
{
@@ -395,7 +395,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_ENCRYPT_DATA_FIELD_DETERMINISTIC
395395
/* encrypt the data */
396396
const size_t bufferLength = inputSize + EVP_MAX_BLOCK_LENGTH;
397397
unsigned char* ciphertext = malloc(bufferLength * sizeof(char));
398-
int ciphertext_len = encrypt((unsigned char*)input,(int)inputSize,(unsigned char*)mEncryptionKey,(unsigned char*)mEncryptionIV,ciphertext,&encryptionErrorData);
398+
size_t ciphertext_len = encrypt((unsigned char*)input,(int64_t)inputSize,(unsigned char*)mEncryptionKey,(unsigned char*)mEncryptionIV,ciphertext,&encryptionErrorData);
399399
if (!(encryptionErrorData.mErrorOccurred))
400400
{
401401
if (((size_t) ciphertext_len) < maxResultSize)
@@ -417,7 +417,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_ENCRYPT_DATA_FIELD_DETERMINISTIC
417417

418418

419419
/* Function used to decrypt a data value (deterministic methods.)
420-
* See the function prototype defintions for more information.
420+
* See the function prototype definitions for more information.
421421
*/
422422
G2_ENCRYPTION_PLUGIN_FUNCTION_DECRYPT_DATA_FIELD_DETERMINISTIC
423423
{
@@ -427,7 +427,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_DECRYPT_DATA_FIELD_DETERMINISTIC
427427
/* decrypt the data */
428428
const size_t bufferLength = inputSize + EVP_MAX_BLOCK_LENGTH;
429429
unsigned char* decryptedtext = malloc(bufferLength * sizeof(char));
430-
int decryptedtext_len = decrypt((unsigned char*)input,(int)inputSize,(unsigned char*)mEncryptionKey,(unsigned char*)mEncryptionIV,decryptedtext,&decryptionErrorData);
430+
size_t decryptedtext_len = decrypt((unsigned char*)input,(int64_t)inputSize,(unsigned char*)mEncryptionKey,(unsigned char*)mEncryptionIV,decryptedtext,&decryptionErrorData);
431431
if (!(decryptionErrorData.mErrorOccurred))
432432
{
433433
if (((size_t) decryptedtext_len) < maxResultSize)

src/encryptionPlugins/EncryptDataClearTextPlugin.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/**********************************************************************************
3-
© Copyright Senzing, Inc. 2020-2024
3+
© Copyright Senzing, Inc. 2020-2025
44
The source code for this program is not published or otherwise divested
55
of its trade secrets, irrespective of what has been deposited with the U.S.
66
Copyright Office.
@@ -20,7 +20,7 @@ const char* getPluginSignature()
2020

2121

2222
/* Function used to initialize a plugin.
23-
* See the function prototype defintions for more information.
23+
* See the function prototype definitions for more information.
2424
*/
2525
G2_ENCRYPTION_PLUGIN_FUNCTION_INIT_PLUGIN
2626
{
@@ -36,7 +36,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_INIT_PLUGIN
3636

3737

3838
/* Function used to close a plugin.
39-
* See the function prototype defintions for more information.
39+
* See the function prototype definitions for more information.
4040
*/
4141
G2_ENCRYPTION_PLUGIN_FUNCTION_CLOSE_PLUGIN
4242
{
@@ -52,7 +52,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_CLOSE_PLUGIN
5252

5353

5454
/* Function used to retrieve the plugin signature.
55-
* See the function prototype defintions for more information.
55+
* See the function prototype definitions for more information.
5656
*/
5757
G2_ENCRYPTION_PLUGIN_FUNCTION_GET_SIGNATURE
5858
{
@@ -85,7 +85,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_GET_SIGNATURE
8585

8686

8787
/* Function used to validate the plugin signature compatibility.
88-
* See the function prototype defintions for more information.
88+
* See the function prototype definitions for more information.
8989
*/
9090
G2_ENCRYPTION_PLUGIN_FUNCTION_VALIDATE_SIGNATURE_COMPATIBILITY
9191
{
@@ -107,7 +107,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_VALIDATE_SIGNATURE_COMPATIBILITY
107107

108108

109109
/* Function used to encrypt a data value.
110-
* See the function prototype defintions for more information.
110+
* See the function prototype definitions for more information.
111111
*/
112112
G2_ENCRYPTION_PLUGIN_FUNCTION_ENCRYPT_DATA_FIELD
113113
{
@@ -135,7 +135,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_ENCRYPT_DATA_FIELD
135135

136136

137137
/* Function used to decrypt a data value.
138-
* See the function prototype defintions for more information.
138+
* See the function prototype definitions for more information.
139139
*/
140140
G2_ENCRYPTION_PLUGIN_FUNCTION_DECRYPT_DATA_FIELD
141141
{
@@ -163,7 +163,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_DECRYPT_DATA_FIELD
163163

164164

165165
/* Function used to encrypt a data value (deterministic methods.)
166-
* See the function prototype defintions for more information.
166+
* See the function prototype definitions for more information.
167167
*/
168168
G2_ENCRYPTION_PLUGIN_FUNCTION_ENCRYPT_DATA_FIELD_DETERMINISTIC
169169
{
@@ -191,7 +191,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_ENCRYPT_DATA_FIELD_DETERMINISTIC
191191

192192

193193
/* Function used to decrypt a data value (deterministic methods.)
194-
* See the function prototype defintions for more information.
194+
* See the function prototype definitions for more information.
195195
*/
196196
G2_ENCRYPTION_PLUGIN_FUNCTION_DECRYPT_DATA_FIELD_DETERMINISTIC
197197
{

src/encryptionPlugins/EncryptDataReverseTextPlugin.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/**********************************************************************************
3-
© Copyright Senzing, Inc. 2023-2024
3+
© Copyright Senzing, Inc. 2023-2025
44
The source code for this program is not published or otherwise divested
55
of its trade secrets, irrespective of what has been deposited with the U.S.
66
Copyright Office.
@@ -20,7 +20,7 @@ const char* getPluginSignature()
2020

2121

2222
/* Function used to initialize a plugin.
23-
* See the function prototype defintions for more information.
23+
* See the function prototype definitions for more information.
2424
*/
2525
G2_ENCRYPTION_PLUGIN_FUNCTION_INIT_PLUGIN
2626
{
@@ -36,7 +36,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_INIT_PLUGIN
3636

3737

3838
/* Function used to close a plugin.
39-
* See the function prototype defintions for more information.
39+
* See the function prototype definitions for more information.
4040
*/
4141
G2_ENCRYPTION_PLUGIN_FUNCTION_CLOSE_PLUGIN
4242
{
@@ -52,7 +52,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_CLOSE_PLUGIN
5252

5353

5454
/* Function used to retrieve the plugin signature.
55-
* See the function prototype defintions for more information.
55+
* See the function prototype definitions for more information.
5656
*/
5757
G2_ENCRYPTION_PLUGIN_FUNCTION_GET_SIGNATURE
5858
{
@@ -85,7 +85,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_GET_SIGNATURE
8585

8686

8787
/* Function used to validate the plugin signature compatibility.
88-
* See the function prototype defintions for more information.
88+
* See the function prototype definitions for more information.
8989
*/
9090
G2_ENCRYPTION_PLUGIN_FUNCTION_VALIDATE_SIGNATURE_COMPATIBILITY
9191
{
@@ -123,7 +123,7 @@ void reverseContentsOfBuffer(char *buffer,const size_t bufferSizeToReverse)
123123

124124

125125
/* Function used to encrypt a data value.
126-
* See the function prototype defintions for more information.
126+
* See the function prototype definitions for more information.
127127
*/
128128
G2_ENCRYPTION_PLUGIN_FUNCTION_ENCRYPT_DATA_FIELD
129129
{
@@ -152,7 +152,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_ENCRYPT_DATA_FIELD
152152

153153

154154
/* Function used to decrypt a data value.
155-
* See the function prototype defintions for more information.
155+
* See the function prototype definitions for more information.
156156
*/
157157
G2_ENCRYPTION_PLUGIN_FUNCTION_DECRYPT_DATA_FIELD
158158
{
@@ -181,7 +181,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_DECRYPT_DATA_FIELD
181181

182182

183183
/* Function used to encrypt a data value (deterministic methods.)
184-
* See the function prototype defintions for more information.
184+
* See the function prototype definitions for more information.
185185
*/
186186
G2_ENCRYPTION_PLUGIN_FUNCTION_ENCRYPT_DATA_FIELD_DETERMINISTIC
187187
{
@@ -210,7 +210,7 @@ G2_ENCRYPTION_PLUGIN_FUNCTION_ENCRYPT_DATA_FIELD_DETERMINISTIC
210210

211211

212212
/* Function used to decrypt a data value (deterministic methods.)
213-
* See the function prototype defintions for more information.
213+
* See the function prototype definitions for more information.
214214
*/
215215
G2_ENCRYPTION_PLUGIN_FUNCTION_DECRYPT_DATA_FIELD_DETERMINISTIC
216216
{

0 commit comments

Comments
 (0)