Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/evp/e_xcbc_d.c |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | /* | - | ||||||
2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. | - | ||||||
3 | * | - | ||||||
4 | * Licensed under the OpenSSL license (the "License"). You may not use | - | ||||||
5 | * this file except in compliance with the License. You can obtain a copy | - | ||||||
6 | * in the file LICENSE in the source distribution or at | - | ||||||
7 | * https://www.openssl.org/source/license.html | - | ||||||
8 | */ | - | ||||||
9 | - | |||||||
10 | #include <stdio.h> | - | ||||||
11 | #include "internal/cryptlib.h" | - | ||||||
12 | - | |||||||
13 | #ifndef OPENSSL_NO_DES | - | ||||||
14 | - | |||||||
15 | # include <openssl/evp.h> | - | ||||||
16 | # include <openssl/objects.h> | - | ||||||
17 | # include "internal/evp_int.h" | - | ||||||
18 | # include <openssl/des.h> | - | ||||||
19 | - | |||||||
20 | static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | - | ||||||
21 | const unsigned char *iv, int enc); | - | ||||||
22 | static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | - | ||||||
23 | const unsigned char *in, size_t inl); | - | ||||||
24 | - | |||||||
25 | typedef struct { | - | ||||||
26 | DES_key_schedule ks; /* key schedule */ | - | ||||||
27 | DES_cblock inw; | - | ||||||
28 | DES_cblock outw; | - | ||||||
29 | } DESX_CBC_KEY; | - | ||||||
30 | - | |||||||
31 | # define data(ctx) EVP_C_DATA(DESX_CBC_KEY,ctx) | - | ||||||
32 | - | |||||||
33 | static const EVP_CIPHER d_xcbc_cipher = { | - | ||||||
34 | NID_desx_cbc, | - | ||||||
35 | 8, 24, 8, | - | ||||||
36 | EVP_CIPH_CBC_MODE, | - | ||||||
37 | desx_cbc_init_key, | - | ||||||
38 | desx_cbc_cipher, | - | ||||||
39 | NULL, | - | ||||||
40 | sizeof(DESX_CBC_KEY), | - | ||||||
41 | EVP_CIPHER_set_asn1_iv, | - | ||||||
42 | EVP_CIPHER_get_asn1_iv, | - | ||||||
43 | NULL, | - | ||||||
44 | NULL | - | ||||||
45 | }; | - | ||||||
46 | - | |||||||
47 | const EVP_CIPHER *EVP_desx_cbc(void) | - | ||||||
48 | { | - | ||||||
49 | return &d_xcbc_cipher; executed 1962 times by 1 test: return &d_xcbc_cipher; Executed by:
| 1962 | ||||||
50 | } | - | ||||||
51 | - | |||||||
52 | static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | - | ||||||
53 | const unsigned char *iv, int enc) | - | ||||||
54 | { | - | ||||||
55 | DES_cblock *deskey = (DES_cblock *)key; | - | ||||||
56 | - | |||||||
57 | DES_set_key_unchecked(deskey, &data(ctx)->ks); | - | ||||||
58 | memcpy(&data(ctx)->inw[0], &key[8], 8); | - | ||||||
59 | memcpy(&data(ctx)->outw[0], &key[16], 8); | - | ||||||
60 | - | |||||||
61 | return 1; executed 32 times by 1 test: return 1; Executed by:
| 32 | ||||||
62 | } | - | ||||||
63 | - | |||||||
64 | static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | - | ||||||
65 | const unsigned char *in, size_t inl) | - | ||||||
66 | { | - | ||||||
67 | while (inl >= EVP_MAXCHUNK) {
| 0-180 | ||||||
68 | DES_xcbc_encrypt(in, out, (long)EVP_MAXCHUNK, &data(ctx)->ks, | - | ||||||
69 | (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx), | - | ||||||
70 | &data(ctx)->inw, &data(ctx)->outw, | - | ||||||
71 | EVP_CIPHER_CTX_encrypting(ctx)); | - | ||||||
72 | inl -= EVP_MAXCHUNK; | - | ||||||
73 | in += EVP_MAXCHUNK; | - | ||||||
74 | out += EVP_MAXCHUNK; | - | ||||||
75 | } never executed: end of block | 0 | ||||||
76 | if (inl)
| 0-180 | ||||||
77 | DES_xcbc_encrypt(in, out, (long)inl, &data(ctx)->ks, executed 180 times by 1 test: DES_xcbc_encrypt(in, out, (long)inl, &((DESX_CBC_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->ks, (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx), &((DESX_CBC_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->inw, &((DESX_CBC_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->outw, EVP_CIPHER_CTX_encrypting(ctx)); Executed by:
| 180 | ||||||
78 | (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx), executed 180 times by 1 test: DES_xcbc_encrypt(in, out, (long)inl, &((DESX_CBC_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->ks, (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx), &((DESX_CBC_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->inw, &((DESX_CBC_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->outw, EVP_CIPHER_CTX_encrypting(ctx)); Executed by:
| 180 | ||||||
79 | &data(ctx)->inw, &data(ctx)->outw, executed 180 times by 1 test: DES_xcbc_encrypt(in, out, (long)inl, &((DESX_CBC_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->ks, (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx), &((DESX_CBC_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->inw, &((DESX_CBC_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->outw, EVP_CIPHER_CTX_encrypting(ctx)); Executed by:
| 180 | ||||||
80 | EVP_CIPHER_CTX_encrypting(ctx)); executed 180 times by 1 test: DES_xcbc_encrypt(in, out, (long)inl, &((DESX_CBC_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->ks, (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx), &((DESX_CBC_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->inw, &((DESX_CBC_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->outw, EVP_CIPHER_CTX_encrypting(ctx)); Executed by:
| 180 | ||||||
81 | return 1; executed 180 times by 1 test: return 1; Executed by:
| 180 | ||||||
82 | } | - | ||||||
83 | #endif | - | ||||||
Source code | Switch to Preprocessed file |