Debian Codegraph @

test/kcapi-enc-test-large.c

raw symbols SCIP
1 /*
2 * Copyright (C) 2017 - 2022, Stephan Mueller <[email protected]>
3 *
4 * License: see LICENSE file in root directory
5 *
6 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
7 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
8 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
9 * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
10 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
11 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
12 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
13 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
14 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
15 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
16 * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
17 * DAMAGE.
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 //printf("round %d\n", i);
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 }