Welcome to leancrypto Discussions! #8
Replies: 6 comments 1 reply
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
Am Mittwoch, 23. Oktober 2024, 22:03:46 Mitteleuropäische Sommerzeit schrieb
SID:
Hi SID,
Hi,
I want to know how to use leanCrypto API.
I have build the library and test. It ran successfully.
I need to use AEAD and HASH independently but while using the test files
directly I am getting into error.
You can either look at one of the following:
- the lc_aead.h or lc_hash.h for the API description
- check the Doxygen documentation (specifically the Topics section) at [1]
- look at the sample code in the test cases in aead/tests and hash/tests.
Note, the key concept of leancrypto is that the caller must allocate or
initialize the cipher handle for the intended particular algorithm and then
use the common APIs.
[1] https://leancrypto.org/leancrypto/doxygen/html/index.html
Ciao
Stephan
|
Beta Was this translation helpful? Give feedback.
-
Thank you, Sir for your reply!! Can you please help me out in figuring out how can I make a simple C code using leancrypto APIS. I am trying this standalone code from the test cases provided in API but getting error.
|
Beta Was this translation helpful? Give feedback.
-
Am Mittwoch, 23. Oktober 2024, 22:35:23 Mitteleuropäische Sommerzeit schrieb
SID:
Hi SID,
Thank you, Sir for your reply!!
I have compiled without Doxygen installed. This Documentation is of great
importance to me as I am new in Cryptography field.
Can you please help me out in figuring out how can I make a simple C code
using leancrypto APIS. I am trying this standalone code from the test cases
provided in API but getting error. FileName : crypto_exp1.c
#include <errno.h>
#include <stdlib.h>
#include <leancrypto.h>
int main(){
LC_AK_CTX_ON_STACK(ak, lc_sha3_256);
uint8_t tag[16];
uint8_t *pt;
uint8_t aad[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
uint8_t key[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f };
uint8_t iv[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
};
size_t len;
int ret;
CKINT(test_mem(&pt, &len));
if (lc_aead_setkey(ak, key, sizeof(key), iv, sizeof(iv))) {
ret = EFAULT;
goto out;
}
lc_aead_encrypt(ak, pt, pt, len, aad, sizeof(aad), tag, sizeof(tag));
lc_aead_zero(ak);
if (lc_aead_setkey(ak, key, sizeof(key), iv, sizeof(iv))) {
ret = EFAULT;
goto out;
}
ret = lc_aead_decrypt(ak, pt, pt, len, aad, sizeof(aad), tag,
sizeof(tag));
lc_aead_zero(ak);
out:
free(pt);
return ret;
}
(base) ***@***.***:~/Crypto_exp$ gcc crypto_exp1.c -o crypto_exp1_exec -lm
crypto_exp1.c: In function ‘main’:
crypto_exp1.c:46:5: warning: implicit declaration of function ‘CKINT’
[-Wimplicit-function-declaration] 46 | CKINT(test_mem(&pt, &len));
| ^~~~~
crypto_exp1.c:46:11: warning: implicit declaration of function ‘test_mem’
[-Wimplicit-function-declaration] 46 | CKINT(test_mem(&pt, &len));
| ^~~~~~~~
/usr/bin/ld: /tmp/ccZKI2Uf.o: warning: relocation against `lc_sha3_256' in
read-only section `.text' /usr/bin/ld: /tmp/ccZKI2Uf.o: in function `main':
crypto_exp1.c:(.text+0x3e): undefined reference to `lc_ascon_aead'
/usr/bin/ld: crypto_exp1.c:(.text+0x9e): undefined reference to
`lc_sha3_256' /usr/bin/ld: crypto_exp1.c:(.text+0x130): undefined reference
to `test_mem' /usr/bin/ld: crypto_exp1.c:(.text+0x13c): undefined reference
to `CKINT' /usr/bin/ld: crypto_exp1.c:(.text+0x161): undefined reference to
`lc_aead_setkey' /usr/bin/ld: crypto_exp1.c:(.text+0x1ac): undefined
reference to `lc_aead_encrypt' /usr/bin/ld: crypto_exp1.c:(.text+0x1bf):
undefined reference to `lc_aead_zero' /usr/bin/ld:
crypto_exp1.c:(.text+0x1e4): undefined reference to `lc_aead_setkey'
/usr/bin/ld: crypto_exp1.c:(.text+0x22c): undefined reference to
`lc_aead_decrypt' /usr/bin/ld: crypto_exp1.c:(.text+0x245): undefined
reference to `lc_aead_zero' /usr/bin/ld: warning: creating DT_TEXTREL in a
PIE
collect2: error: ld returned 1 exit status
Well, follow what the compiler tells you: the test_mem function is not defined
in your code. The test code uses a separate helper to allocate memory. This is
totally unrelated to leancrypto. You need to allocate / provide the plaintext
buffer which the code above refers to with the pt variable. After allocation,
you need to fill it with your data.
Ciao
Stephan
|
Beta Was this translation helpful? Give feedback.
-
Hi Stephan, Just curious if we can use leancypto for production/commercial (very specific use case only) software, and is there any paid-support provided by you or atsec ? Thanks & Regards, |
Beta Was this translation helpful? Give feedback.
-
Am Montag, 3. Februar 2025, 23:26:57 CET schrieb sureshkei:
Hi sureshkei,
Hi Stephan,
Thanks for the great work on leancrypto.
Thank you.
Just curious if we can use leancypto for production/commercial (very
specific use case only) software, and is there any paid-support provided by
you or atsec ?
First of all, atsec is not involved in the development of leancrypto. As such,
atsec does not provide any support for this library. I am just an employee of
atsec and develop that library in my spare time. Furthermore,
atsec agreed that he uses the atsec address for obtaining official ACVP
certificates as privately I cannot obtain such certificates. atsec offers FIPS
140 services where this library could be validated under FIPS 140 as well as
to obtain CAVP certificates. In this case, I personally will not be part of
the FIPS test team to ensure proper separation of duties.
As this library is Open Source with a dual license of GPLv2 and BSD, it is
permissible to use this library pursuant to these license rules.
Ciao
Stephan
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
👋 Welcome!
We’re using Discussions as a place to connect with other members of our community. We hope that you:
build together 💪.
To get started, comment below with an introduction of yourself and tell us about what you do with this community.
Beta Was this translation helpful? Give feedback.
All reactions