| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#include <stdio.h> |
| 21 |
#include <kcapi.h> |
| 22 |
|
| 23 |
int main(int argc, char *argv[]) |
| 24 |
{ |
| 25 |
char buf[8192]; |
| 26 |
struct kcapi_handle *handle; |
| 27 |
struct iovec iov; |
| 28 |
ssize_t ret; |
| 29 |
int i; |
| 30 |
|
| 31 |
(void)argc; |
| 32 |
(void)argv; |
| 33 |
|
| 34 |
iov.iov_base = buf; |
| 35 |
|
| 36 |
ret = kcapi_cipher_init(&handle, "cbc(aes)", 0); |
| 37 |
if (ret) |
| 38 |
return (int)ret; |
| 39 |
|
| 40 |
ret = kcapi_cipher_setkey(handle, (unsigned char *)"0123456789abcdef", 16); |
| 41 |
if (ret) |
| 42 |
return (int)ret; |
| 43 |
|
| 44 |
ret = kcapi_cipher_stream_init_enc(handle, (unsigned char *)"0123456789abcdef", NULL, 0); |
| 45 |
if (ret < 0) |
| 46 |
return (int)ret; |
| 47 |
|
| 48 |
for (i = 0; i < 100; i++) { |
| 49 |
|
| 50 |
|
| 51 |
iov.iov_len = 6182; |
| 52 |
ret = kcapi_cipher_stream_update(handle, &iov, 1); |
| 53 |
if (ret < 0) |
| 54 |
return (int)ret; |
| 55 |
|
| 56 |
iov.iov_len = 6182; |
| 57 |
ret = kcapi_cipher_stream_op(handle, &iov, 1); |
| 58 |
if (ret < 0) |
| 59 |
return (int)ret; |
| 60 |
} |
| 61 |
|
| 62 |
kcapi_cipher_destroy(handle); |
| 63 |
|
| 64 |
return 0; |
| 65 |
} |