diff --git a/isap/Implementations/crypto_aead/isapa128av20/opt_32/decrypt.c b/isap/Implementations/crypto_aead/isapa128av20/opt_32/decrypt.c new file mode 100644 index 0000000..1fbbdeb --- /dev/null +++ b/isap/Implementations/crypto_aead/isapa128av20/opt_32/decrypt.c @@ -0,0 +1,39 @@ +#include +#include +#include "api.h" +#include "isap.h" + +int crypto_aead_decrypt( + unsigned char *m, unsigned long long *mlen, + unsigned char *nsec, + const unsigned char *c, unsigned long long clen, + const unsigned char *ad, unsigned long long adlen, + const unsigned char *npub, + const unsigned char *k +){ + (void)nsec; + + // Plaintext length is clen - tag length + *mlen = clen-ISAP_TAG_SZ; + + // Generate tag + unsigned char tag[ISAP_TAG_SZ]; + isap_mac(k,npub,ad,adlen,c,*mlen,tag); + + // Compare tag + unsigned long eq_cnt = 0; + for(unsigned int i = 0; i < ISAP_TAG_SZ; i++) { + eq_cnt += (tag[i] == c[(*mlen)+i]); + } + + // Perform decryption if tag is correct + if(eq_cnt == (unsigned long)ISAP_TAG_SZ){ + if (*mlen > 0) { + isap_enc(k,npub,c,*mlen,m); + } + return 0; + } else { + return -1; + } +} + diff --git a/isap/Implementations/crypto_aead/isapa128av20/opt_32_armv67m/decrypt.c b/isap/Implementations/crypto_aead/isapa128av20/opt_32_armv67m/decrypt.c new file mode 100644 index 0000000..1fbbdeb --- /dev/null +++ b/isap/Implementations/crypto_aead/isapa128av20/opt_32_armv67m/decrypt.c @@ -0,0 +1,39 @@ +#include +#include +#include "api.h" +#include "isap.h" + +int crypto_aead_decrypt( + unsigned char *m, unsigned long long *mlen, + unsigned char *nsec, + const unsigned char *c, unsigned long long clen, + const unsigned char *ad, unsigned long long adlen, + const unsigned char *npub, + const unsigned char *k +){ + (void)nsec; + + // Plaintext length is clen - tag length + *mlen = clen-ISAP_TAG_SZ; + + // Generate tag + unsigned char tag[ISAP_TAG_SZ]; + isap_mac(k,npub,ad,adlen,c,*mlen,tag); + + // Compare tag + unsigned long eq_cnt = 0; + for(unsigned int i = 0; i < ISAP_TAG_SZ; i++) { + eq_cnt += (tag[i] == c[(*mlen)+i]); + } + + // Perform decryption if tag is correct + if(eq_cnt == (unsigned long)ISAP_TAG_SZ){ + if (*mlen > 0) { + isap_enc(k,npub,c,*mlen,m); + } + return 0; + } else { + return -1; + } +} + diff --git a/isap/Implementations/crypto_aead/isapa128av20/opt_64/decrypt.c b/isap/Implementations/crypto_aead/isapa128av20/opt_64/decrypt.c new file mode 100644 index 0000000..1fbbdeb --- /dev/null +++ b/isap/Implementations/crypto_aead/isapa128av20/opt_64/decrypt.c @@ -0,0 +1,39 @@ +#include +#include +#include "api.h" +#include "isap.h" + +int crypto_aead_decrypt( + unsigned char *m, unsigned long long *mlen, + unsigned char *nsec, + const unsigned char *c, unsigned long long clen, + const unsigned char *ad, unsigned long long adlen, + const unsigned char *npub, + const unsigned char *k +){ + (void)nsec; + + // Plaintext length is clen - tag length + *mlen = clen-ISAP_TAG_SZ; + + // Generate tag + unsigned char tag[ISAP_TAG_SZ]; + isap_mac(k,npub,ad,adlen,c,*mlen,tag); + + // Compare tag + unsigned long eq_cnt = 0; + for(unsigned int i = 0; i < ISAP_TAG_SZ; i++) { + eq_cnt += (tag[i] == c[(*mlen)+i]); + } + + // Perform decryption if tag is correct + if(eq_cnt == (unsigned long)ISAP_TAG_SZ){ + if (*mlen > 0) { + isap_enc(k,npub,c,*mlen,m); + } + return 0; + } else { + return -1; + } +} + diff --git a/isap/Implementations/crypto_aead/isapa128v20/opt_32/decrypt.c b/isap/Implementations/crypto_aead/isapa128v20/opt_32/decrypt.c new file mode 100644 index 0000000..1fbbdeb --- /dev/null +++ b/isap/Implementations/crypto_aead/isapa128v20/opt_32/decrypt.c @@ -0,0 +1,39 @@ +#include +#include +#include "api.h" +#include "isap.h" + +int crypto_aead_decrypt( + unsigned char *m, unsigned long long *mlen, + unsigned char *nsec, + const unsigned char *c, unsigned long long clen, + const unsigned char *ad, unsigned long long adlen, + const unsigned char *npub, + const unsigned char *k +){ + (void)nsec; + + // Plaintext length is clen - tag length + *mlen = clen-ISAP_TAG_SZ; + + // Generate tag + unsigned char tag[ISAP_TAG_SZ]; + isap_mac(k,npub,ad,adlen,c,*mlen,tag); + + // Compare tag + unsigned long eq_cnt = 0; + for(unsigned int i = 0; i < ISAP_TAG_SZ; i++) { + eq_cnt += (tag[i] == c[(*mlen)+i]); + } + + // Perform decryption if tag is correct + if(eq_cnt == (unsigned long)ISAP_TAG_SZ){ + if (*mlen > 0) { + isap_enc(k,npub,c,*mlen,m); + } + return 0; + } else { + return -1; + } +} + diff --git a/isap/Implementations/crypto_aead/isapa128v20/opt_32_armv67m/decrypt.c b/isap/Implementations/crypto_aead/isapa128v20/opt_32_armv67m/decrypt.c new file mode 100644 index 0000000..1fbbdeb --- /dev/null +++ b/isap/Implementations/crypto_aead/isapa128v20/opt_32_armv67m/decrypt.c @@ -0,0 +1,39 @@ +#include +#include +#include "api.h" +#include "isap.h" + +int crypto_aead_decrypt( + unsigned char *m, unsigned long long *mlen, + unsigned char *nsec, + const unsigned char *c, unsigned long long clen, + const unsigned char *ad, unsigned long long adlen, + const unsigned char *npub, + const unsigned char *k +){ + (void)nsec; + + // Plaintext length is clen - tag length + *mlen = clen-ISAP_TAG_SZ; + + // Generate tag + unsigned char tag[ISAP_TAG_SZ]; + isap_mac(k,npub,ad,adlen,c,*mlen,tag); + + // Compare tag + unsigned long eq_cnt = 0; + for(unsigned int i = 0; i < ISAP_TAG_SZ; i++) { + eq_cnt += (tag[i] == c[(*mlen)+i]); + } + + // Perform decryption if tag is correct + if(eq_cnt == (unsigned long)ISAP_TAG_SZ){ + if (*mlen > 0) { + isap_enc(k,npub,c,*mlen,m); + } + return 0; + } else { + return -1; + } +} + diff --git a/isap/Implementations/crypto_aead/isapa128v20/opt_64/decrypt.c b/isap/Implementations/crypto_aead/isapa128v20/opt_64/decrypt.c new file mode 100644 index 0000000..1fbbdeb --- /dev/null +++ b/isap/Implementations/crypto_aead/isapa128v20/opt_64/decrypt.c @@ -0,0 +1,39 @@ +#include +#include +#include "api.h" +#include "isap.h" + +int crypto_aead_decrypt( + unsigned char *m, unsigned long long *mlen, + unsigned char *nsec, + const unsigned char *c, unsigned long long clen, + const unsigned char *ad, unsigned long long adlen, + const unsigned char *npub, + const unsigned char *k +){ + (void)nsec; + + // Plaintext length is clen - tag length + *mlen = clen-ISAP_TAG_SZ; + + // Generate tag + unsigned char tag[ISAP_TAG_SZ]; + isap_mac(k,npub,ad,adlen,c,*mlen,tag); + + // Compare tag + unsigned long eq_cnt = 0; + for(unsigned int i = 0; i < ISAP_TAG_SZ; i++) { + eq_cnt += (tag[i] == c[(*mlen)+i]); + } + + // Perform decryption if tag is correct + if(eq_cnt == (unsigned long)ISAP_TAG_SZ){ + if (*mlen > 0) { + isap_enc(k,npub,c,*mlen,m); + } + return 0; + } else { + return -1; + } +} + diff --git a/isap/Implementations/crypto_aead/isapk128av20/opt_32_armv6m/decrypt.c b/isap/Implementations/crypto_aead/isapk128av20/opt_32_armv6m/decrypt.c new file mode 100644 index 0000000..1fbbdeb --- /dev/null +++ b/isap/Implementations/crypto_aead/isapk128av20/opt_32_armv6m/decrypt.c @@ -0,0 +1,39 @@ +#include +#include +#include "api.h" +#include "isap.h" + +int crypto_aead_decrypt( + unsigned char *m, unsigned long long *mlen, + unsigned char *nsec, + const unsigned char *c, unsigned long long clen, + const unsigned char *ad, unsigned long long adlen, + const unsigned char *npub, + const unsigned char *k +){ + (void)nsec; + + // Plaintext length is clen - tag length + *mlen = clen-ISAP_TAG_SZ; + + // Generate tag + unsigned char tag[ISAP_TAG_SZ]; + isap_mac(k,npub,ad,adlen,c,*mlen,tag); + + // Compare tag + unsigned long eq_cnt = 0; + for(unsigned int i = 0; i < ISAP_TAG_SZ; i++) { + eq_cnt += (tag[i] == c[(*mlen)+i]); + } + + // Perform decryption if tag is correct + if(eq_cnt == (unsigned long)ISAP_TAG_SZ){ + if (*mlen > 0) { + isap_enc(k,npub,c,*mlen,m); + } + return 0; + } else { + return -1; + } +} + diff --git a/isap/Implementations/crypto_aead/isapk128av20/opt_32_armv7m/decrypt.c b/isap/Implementations/crypto_aead/isapk128av20/opt_32_armv7m/decrypt.c new file mode 100644 index 0000000..1fbbdeb --- /dev/null +++ b/isap/Implementations/crypto_aead/isapk128av20/opt_32_armv7m/decrypt.c @@ -0,0 +1,39 @@ +#include +#include +#include "api.h" +#include "isap.h" + +int crypto_aead_decrypt( + unsigned char *m, unsigned long long *mlen, + unsigned char *nsec, + const unsigned char *c, unsigned long long clen, + const unsigned char *ad, unsigned long long adlen, + const unsigned char *npub, + const unsigned char *k +){ + (void)nsec; + + // Plaintext length is clen - tag length + *mlen = clen-ISAP_TAG_SZ; + + // Generate tag + unsigned char tag[ISAP_TAG_SZ]; + isap_mac(k,npub,ad,adlen,c,*mlen,tag); + + // Compare tag + unsigned long eq_cnt = 0; + for(unsigned int i = 0; i < ISAP_TAG_SZ; i++) { + eq_cnt += (tag[i] == c[(*mlen)+i]); + } + + // Perform decryption if tag is correct + if(eq_cnt == (unsigned long)ISAP_TAG_SZ){ + if (*mlen > 0) { + isap_enc(k,npub,c,*mlen,m); + } + return 0; + } else { + return -1; + } +} + diff --git a/isap/Implementations/crypto_aead/isapk128v20/opt_32_armv6m/decrypt.c b/isap/Implementations/crypto_aead/isapk128v20/opt_32_armv6m/decrypt.c new file mode 100644 index 0000000..1fbbdeb --- /dev/null +++ b/isap/Implementations/crypto_aead/isapk128v20/opt_32_armv6m/decrypt.c @@ -0,0 +1,39 @@ +#include +#include +#include "api.h" +#include "isap.h" + +int crypto_aead_decrypt( + unsigned char *m, unsigned long long *mlen, + unsigned char *nsec, + const unsigned char *c, unsigned long long clen, + const unsigned char *ad, unsigned long long adlen, + const unsigned char *npub, + const unsigned char *k +){ + (void)nsec; + + // Plaintext length is clen - tag length + *mlen = clen-ISAP_TAG_SZ; + + // Generate tag + unsigned char tag[ISAP_TAG_SZ]; + isap_mac(k,npub,ad,adlen,c,*mlen,tag); + + // Compare tag + unsigned long eq_cnt = 0; + for(unsigned int i = 0; i < ISAP_TAG_SZ; i++) { + eq_cnt += (tag[i] == c[(*mlen)+i]); + } + + // Perform decryption if tag is correct + if(eq_cnt == (unsigned long)ISAP_TAG_SZ){ + if (*mlen > 0) { + isap_enc(k,npub,c,*mlen,m); + } + return 0; + } else { + return -1; + } +} + diff --git a/isap/Implementations/crypto_aead/isapk128v20/opt_32_armv7m/decrypt.c b/isap/Implementations/crypto_aead/isapk128v20/opt_32_armv7m/decrypt.c new file mode 100644 index 0000000..1fbbdeb --- /dev/null +++ b/isap/Implementations/crypto_aead/isapk128v20/opt_32_armv7m/decrypt.c @@ -0,0 +1,39 @@ +#include +#include +#include "api.h" +#include "isap.h" + +int crypto_aead_decrypt( + unsigned char *m, unsigned long long *mlen, + unsigned char *nsec, + const unsigned char *c, unsigned long long clen, + const unsigned char *ad, unsigned long long adlen, + const unsigned char *npub, + const unsigned char *k +){ + (void)nsec; + + // Plaintext length is clen - tag length + *mlen = clen-ISAP_TAG_SZ; + + // Generate tag + unsigned char tag[ISAP_TAG_SZ]; + isap_mac(k,npub,ad,adlen,c,*mlen,tag); + + // Compare tag + unsigned long eq_cnt = 0; + for(unsigned int i = 0; i < ISAP_TAG_SZ; i++) { + eq_cnt += (tag[i] == c[(*mlen)+i]); + } + + // Perform decryption if tag is correct + if(eq_cnt == (unsigned long)ISAP_TAG_SZ){ + if (*mlen > 0) { + isap_enc(k,npub,c,*mlen,m); + } + return 0; + } else { + return -1; + } +} +