OpenCoverage

i_skey.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/idea/i_skey.c
Source codeSwitch to Preprocessed file
LineSourceCount
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 <openssl/idea.h>-
11#include "idea_lcl.h"-
12-
13static IDEA_INT inverse(unsigned int xin);-
14void IDEA_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks)-
15{-
16 int i;-
17 register IDEA_INT *kt, *kf, r0, r1, r2;-
18-
19 kt = &(ks->data[0][0]);-
20 n2s(key, kt[0]);-
21 n2s(key, kt[1]);-
22 n2s(key, kt[2]);-
23 n2s(key, kt[3]);-
24 n2s(key, kt[4]);-
25 n2s(key, kt[5]);-
26 n2s(key, kt[6]);-
27 n2s(key, kt[7]);-
28-
29 kf = kt;-
30 kt += 8;-
31 for (i = 0; i < 6; i++) {
i < 6Description
TRUEevaluated 1362 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-1362
32 r2 = kf[1];-
33 r1 = kf[2];-
34 *(kt++) = ((r2 << 9) | (r1 >> 7)) & 0xffff;-
35 r0 = kf[3];-
36 *(kt++) = ((r1 << 9) | (r0 >> 7)) & 0xffff;-
37 r1 = kf[4];-
38 *(kt++) = ((r0 << 9) | (r1 >> 7)) & 0xffff;-
39 r0 = kf[5];-
40 *(kt++) = ((r1 << 9) | (r0 >> 7)) & 0xffff;-
41 r1 = kf[6];-
42 *(kt++) = ((r0 << 9) | (r1 >> 7)) & 0xffff;-
43 r0 = kf[7];-
44 *(kt++) = ((r1 << 9) | (r0 >> 7)) & 0xffff;-
45 r1 = kf[0];-
46 if (i >= 5)
i >= 5Description
TRUEevaluated 227 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1135 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
227-1135
47 break;
executed 227 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
227
48 *(kt++) = ((r0 << 9) | (r1 >> 7)) & 0xffff;-
49 *(kt++) = ((r1 << 9) | (r2 >> 7)) & 0xffff;-
50 kf += 8;-
51 }
executed 1135 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1135
52}
executed 227 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
227
53-
54void IDEA_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk)-
55{-
56 int r;-
57 register IDEA_INT *fp, *tp, t;-
58-
59 tp = &(dk->data[0][0]);-
60 fp = &(ek->data[8][0]);-
61 for (r = 0; r < 9; r++) {
r < 9Description
TRUEevaluated 720 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-720
62 *(tp++) = inverse(fp[0]);-
63 *(tp++) = ((int)(0x10000L - fp[2]) & 0xffff);-
64 *(tp++) = ((int)(0x10000L - fp[1]) & 0xffff);-
65 *(tp++) = inverse(fp[3]);-
66 if (r == 8)
r == 8Description
TRUEevaluated 80 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 640 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
80-640
67 break;
executed 80 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
80
68 fp -= 6;-
69 *(tp++) = fp[4];-
70 *(tp++) = fp[5];-
71 }
executed 640 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
640
72-
73 tp = &(dk->data[0][0]);-
74 t = tp[1];-
75 tp[1] = tp[2];-
76 tp[2] = t;-
77-
78 t = tp[49];-
79 tp[49] = tp[50];-
80 tp[50] = t;-
81}
executed 80 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
80
82-
83/* taken directly from the 'paper' I'll have a look at it later */-
84static IDEA_INT inverse(unsigned int xin)-
85{-
86 long n1, n2, q, r, b1, b2, t;-
87-
88 if (xin == 0)
xin == 0Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1421 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
19-1421
89 b2 = 0;
executed 19 times by 1 test: b2 = 0;
Executed by:
  • libcrypto.so.1.1
19
90 else {-
91 n1 = 0x10001;-
92 n2 = xin;-
93 b2 = 1;-
94 b1 = 0;-
95-
96 do {-
97 r = (n1 % n2);-
98 q = (n1 - r) / n2;-
99 if (r == 0) {
r == 0Description
TRUEevaluated 1421 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 11841 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1421-11841
100 if (b2 < 0)
b2 < 0Description
TRUEevaluated 753 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 668 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
668-753
101 b2 = 0x10001 + b2;
executed 753 times by 1 test: b2 = 0x10001 + b2;
Executed by:
  • libcrypto.so.1.1
753
102 } else {
executed 1421 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1421
103 n1 = n2;-
104 n2 = r;-
105 t = b2;-
106 b2 = b1 - q * b2;-
107 b1 = t;-
108 }
executed 11841 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
11841
109 } while (r != 0);
r != 0Description
TRUEevaluated 11841 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1421 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1421-11841
110 }
executed 1421 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1421
111 return (IDEA_INT)b2;
executed 1440 times by 1 test: return (IDEA_INT)b2;
Executed by:
  • libcrypto.so.1.1
1440
112}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2