mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-18 04:10:57 +01:00
added raw library encryption test with static keys, cipher and message
This commit is contained in:
20
tests/statictest.c
Normal file
20
tests/statictest.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <pcp.h>
|
||||
#include "static.h"
|
||||
|
||||
int main() {
|
||||
unsigned char *t = ucmalloc(12);
|
||||
if(pcp_sodium_verify_box(&t, cipher, cipher_len, nonce, secret_b, public_a) == 0) {
|
||||
if(memcmp(t, message, message_len) == 0) {
|
||||
printf("ok\n");
|
||||
}
|
||||
else {
|
||||
printf("decrypted but message doesnt match\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("failed to decrypt\n");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user