| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/idea/i_cbc.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 <openssl/idea.h> | - | ||||||||||||||||||||||||
| 11 | #include "idea_lcl.h" | - | ||||||||||||||||||||||||
| 12 | - | |||||||||||||||||||||||||
| 13 | void IDEA_cbc_encrypt(const unsigned char *in, unsigned char *out, | - | ||||||||||||||||||||||||
| 14 | long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, | - | ||||||||||||||||||||||||
| 15 | int encrypt) | - | ||||||||||||||||||||||||
| 16 | { | - | ||||||||||||||||||||||||
| 17 | register unsigned long tin0, tin1; | - | ||||||||||||||||||||||||
| 18 | register unsigned long tout0, tout1, xor0, xor1; | - | ||||||||||||||||||||||||
| 19 | register long l = length; | - | ||||||||||||||||||||||||
| 20 | unsigned long tin[2]; | - | ||||||||||||||||||||||||
| 21 | - | |||||||||||||||||||||||||
| 22 | if (encrypt) {
| 173-349 | ||||||||||||||||||||||||
| 23 | n2l(iv, tout0); | - | ||||||||||||||||||||||||
| 24 | n2l(iv, tout1); | - | ||||||||||||||||||||||||
| 25 | iv -= 8; | - | ||||||||||||||||||||||||
| 26 | for (l -= 8; l >= 0; l -= 8) {
| 349-2501 | ||||||||||||||||||||||||
| 27 | n2l(in, tin0); | - | ||||||||||||||||||||||||
| 28 | n2l(in, tin1); | - | ||||||||||||||||||||||||
| 29 | tin0 ^= tout0; | - | ||||||||||||||||||||||||
| 30 | tin1 ^= tout1; | - | ||||||||||||||||||||||||
| 31 | tin[0] = tin0; | - | ||||||||||||||||||||||||
| 32 | tin[1] = tin1; | - | ||||||||||||||||||||||||
| 33 | IDEA_encrypt(tin, ks); | - | ||||||||||||||||||||||||
| 34 | tout0 = tin[0]; | - | ||||||||||||||||||||||||
| 35 | l2n(tout0, out); | - | ||||||||||||||||||||||||
| 36 | tout1 = tin[1]; | - | ||||||||||||||||||||||||
| 37 | l2n(tout1, out); | - | ||||||||||||||||||||||||
| 38 | } executed 2501 times by 1 test: end of blockExecuted by:
| 2501 | ||||||||||||||||||||||||
| 39 | if (l != -8) {
| 1-348 | ||||||||||||||||||||||||
| 40 | n2ln(in, tin0, tin1, l + 8); executed 1 time by 1 test: end of blockExecuted by:
code before this statement never executed: case 7:code before this statement never executed: case 6:code before this statement executed 1 time by 1 test: case 5:Executed by:
code before this statement executed 1 time by 1 test: case 4:Executed by:
code before this statement executed 1 time by 1 test: case 3:Executed by:
code before this statement executed 1 time by 1 test: case 2:Executed by:
code before this statement executed 1 time by 1 test: case 1:Executed by:
never executed: case 8:never executed: case 7:executed 1 time by 1 test: case 6:Executed by:
never executed: case 5:never executed: case 4:never executed: case 3:never executed: case 2:executed 1 time by 1 test: case 1:Executed by:
| 0-1 | ||||||||||||||||||||||||
| 41 | tin0 ^= tout0; | - | ||||||||||||||||||||||||
| 42 | tin1 ^= tout1; | - | ||||||||||||||||||||||||
| 43 | tin[0] = tin0; | - | ||||||||||||||||||||||||
| 44 | tin[1] = tin1; | - | ||||||||||||||||||||||||
| 45 | IDEA_encrypt(tin, ks); | - | ||||||||||||||||||||||||
| 46 | tout0 = tin[0]; | - | ||||||||||||||||||||||||
| 47 | l2n(tout0, out); | - | ||||||||||||||||||||||||
| 48 | tout1 = tin[1]; | - | ||||||||||||||||||||||||
| 49 | l2n(tout1, out); | - | ||||||||||||||||||||||||
| 50 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 51 | l2n(tout0, iv); | - | ||||||||||||||||||||||||
| 52 | l2n(tout1, iv); | - | ||||||||||||||||||||||||
| 53 | } else { executed 349 times by 1 test: end of blockExecuted by:
| 349 | ||||||||||||||||||||||||
| 54 | n2l(iv, xor0); | - | ||||||||||||||||||||||||
| 55 | n2l(iv, xor1); | - | ||||||||||||||||||||||||
| 56 | iv -= 8; | - | ||||||||||||||||||||||||
| 57 | for (l -= 8; l >= 0; l -= 8) {
| 173-6985 | ||||||||||||||||||||||||
| 58 | n2l(in, tin0); | - | ||||||||||||||||||||||||
| 59 | tin[0] = tin0; | - | ||||||||||||||||||||||||
| 60 | n2l(in, tin1); | - | ||||||||||||||||||||||||
| 61 | tin[1] = tin1; | - | ||||||||||||||||||||||||
| 62 | IDEA_encrypt(tin, ks); | - | ||||||||||||||||||||||||
| 63 | tout0 = tin[0] ^ xor0; | - | ||||||||||||||||||||||||
| 64 | tout1 = tin[1] ^ xor1; | - | ||||||||||||||||||||||||
| 65 | l2n(tout0, out); | - | ||||||||||||||||||||||||
| 66 | l2n(tout1, out); | - | ||||||||||||||||||||||||
| 67 | xor0 = tin0; | - | ||||||||||||||||||||||||
| 68 | xor1 = tin1; | - | ||||||||||||||||||||||||
| 69 | } executed 6985 times by 1 test: end of blockExecuted by:
| 6985 | ||||||||||||||||||||||||
| 70 | if (l != -8) {
| 1-172 | ||||||||||||||||||||||||
| 71 | n2l(in, tin0); | - | ||||||||||||||||||||||||
| 72 | tin[0] = tin0; | - | ||||||||||||||||||||||||
| 73 | n2l(in, tin1); | - | ||||||||||||||||||||||||
| 74 | tin[1] = tin1; | - | ||||||||||||||||||||||||
| 75 | IDEA_encrypt(tin, ks); | - | ||||||||||||||||||||||||
| 76 | tout0 = tin[0] ^ xor0; | - | ||||||||||||||||||||||||
| 77 | tout1 = tin[1] ^ xor1; | - | ||||||||||||||||||||||||
| 78 | l2nn(tout0, tout1, out, l + 8); executed 1 time by 1 test: end of blockExecuted by:
code before this statement never executed: case 7:code before this statement never executed: case 6:code before this statement executed 1 time by 1 test: case 5:Executed by:
code before this statement executed 1 time by 1 test: case 4:Executed by:
code before this statement executed 1 time by 1 test: case 3:Executed by:
code before this statement executed 1 time by 1 test: case 2:Executed by:
code before this statement executed 1 time by 1 test: case 1:Executed by:
never executed: case 8:never executed: case 7:executed 1 time by 1 test: case 6:Executed by:
never executed: case 5:never executed: case 4:never executed: case 3:never executed: case 2:executed 1 time by 1 test: case 1:Executed by:
| 0-1 | ||||||||||||||||||||||||
| 79 | xor0 = tin0; | - | ||||||||||||||||||||||||
| 80 | xor1 = tin1; | - | ||||||||||||||||||||||||
| 81 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 82 | l2n(xor0, iv); | - | ||||||||||||||||||||||||
| 83 | l2n(xor1, iv); | - | ||||||||||||||||||||||||
| 84 | } executed 173 times by 1 test: end of blockExecuted by:
| 173 | ||||||||||||||||||||||||
| 85 | tin0 = tin1 = tout0 = tout1 = xor0 = xor1 = 0; | - | ||||||||||||||||||||||||
| 86 | tin[0] = tin[1] = 0; | - | ||||||||||||||||||||||||
| 87 | } executed 522 times by 1 test: end of blockExecuted by:
| 522 | ||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||
| 89 | void IDEA_encrypt(unsigned long *d, IDEA_KEY_SCHEDULE *key) | - | ||||||||||||||||||||||||
| 90 | { | - | ||||||||||||||||||||||||
| 91 | register IDEA_INT *p; | - | ||||||||||||||||||||||||
| 92 | register unsigned long x1, x2, x3, x4, t0, t1, ul; | - | ||||||||||||||||||||||||
| 93 | - | |||||||||||||||||||||||||
| 94 | x2 = d[0]; | - | ||||||||||||||||||||||||
| 95 | x1 = (x2 >> 16); | - | ||||||||||||||||||||||||
| 96 | x4 = d[1]; | - | ||||||||||||||||||||||||
| 97 | x3 = (x4 >> 16); | - | ||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||
| 99 | p = &(key->data[0][0]); | - | ||||||||||||||||||||||||
| 100 | - | |||||||||||||||||||||||||
| 101 | E_IDEA(0); executed 12445 times by 1 test: end of blockExecuted by:
executed 1763 times by 1 test: x1=(-(int)x1-*p+1);Executed by:
executed 12483 times by 1 test: end of blockExecuted by:
executed 1725 times by 1 test: x4=(-(int)x4-*p+1);Executed by:
executed 14168 times by 1 test: end of blockExecuted by:
executed 40 times by 1 test: t0=(-(int)t0-*p+1);Executed by:
executed 14144 times by 1 test: end of blockExecuted by:
executed 64 times by 1 test: t1=(-(int)t1-*p+1);Executed by:
| 40-14168 | ||||||||||||||||||||||||
| 102 | E_IDEA(1); executed 14196 times by 1 test: end of blockExecuted by:
executed 12 times by 1 test: x1=(-(int)x1-*p+1);Executed by:
executed 14185 times by 1 test: end of blockExecuted by:
executed 23 times by 1 test: x4=(-(int)x4-*p+1);Executed by:
executed 14192 times by 1 test: end of blockExecuted by:
executed 16 times by 1 test: t0=(-(int)t0-*p+1);Executed by:
executed 14164 times by 1 test: end of blockExecuted by:
executed 44 times by 1 test: t1=(-(int)t1-*p+1);Executed by:
| 12-14196 | ||||||||||||||||||||||||
| 103 | E_IDEA(2); executed 14179 times by 1 test: end of blockExecuted by:
executed 29 times by 1 test: x1=(-(int)x1-*p+1);Executed by:
executed 14148 times by 1 test: end of blockExecuted by:
executed 60 times by 1 test: x4=(-(int)x4-*p+1);Executed by:
executed 14176 times by 1 test: end of blockExecuted by:
executed 32 times by 1 test: t0=(-(int)t0-*p+1);Executed by:
executed 14199 times by 1 test: end of blockExecuted by:
executed 9 times by 1 test: t1=(-(int)t1-*p+1);Executed by:
| 9-14199 | ||||||||||||||||||||||||
| 104 | E_IDEA(3); executed 14197 times by 1 test: end of blockExecuted by:
executed 11 times by 1 test: x1=(-(int)x1-*p+1);Executed by:
executed 14197 times by 1 test: end of blockExecuted by:
executed 11 times by 1 test: x4=(-(int)x4-*p+1);Executed by:
executed 14159 times by 1 test: end of blockExecuted by:
executed 49 times by 1 test: t0=(-(int)t0-*p+1);Executed by:
executed 14148 times by 1 test: end of blockExecuted by:
executed 60 times by 1 test: t1=(-(int)t1-*p+1);Executed by:
| 11-14197 | ||||||||||||||||||||||||
| 105 | E_IDEA(4); executed 14200 times by 1 test: end of blockExecuted by:
executed 8 times by 1 test: x1=(-(int)x1-*p+1);Executed by:
executed 14167 times by 1 test: end of blockExecuted by:
executed 41 times by 1 test: x4=(-(int)x4-*p+1);Executed by:
executed 14200 times by 1 test: end of blockExecuted by:
executed 8 times by 1 test: t0=(-(int)t0-*p+1);Executed by:
executed 14176 times by 1 test: end of blockExecuted by:
executed 32 times by 1 test: t1=(-(int)t1-*p+1);Executed by:
| 8-14200 | ||||||||||||||||||||||||
| 106 | E_IDEA(5); executed 14182 times by 1 test: end of blockExecuted by:
executed 26 times by 1 test: x1=(-(int)x1-*p+1);Executed by:
executed 14197 times by 1 test: end of blockExecuted by:
executed 11 times by 1 test: x4=(-(int)x4-*p+1);Executed by:
executed 14142 times by 1 test: end of blockExecuted by:
executed 66 times by 1 test: t0=(-(int)t0-*p+1);Executed by:
executed 14149 times by 1 test: end of blockExecuted by:
executed 59 times by 1 test: t1=(-(int)t1-*p+1);Executed by:
| 11-14197 | ||||||||||||||||||||||||
| 107 | E_IDEA(6); executed 14196 times by 1 test: end of blockExecuted by:
executed 12 times by 1 test: x1=(-(int)x1-*p+1);Executed by:
executed 14164 times by 1 test: end of blockExecuted by:
executed 44 times by 1 test: x4=(-(int)x4-*p+1);Executed by:
executed 14193 times by 1 test: end of blockExecuted by:
executed 15 times by 1 test: t0=(-(int)t0-*p+1);Executed by:
executed 14167 times by 1 test: end of blockExecuted by:
executed 41 times by 1 test: t1=(-(int)t1-*p+1);Executed by:
| 12-14196 | ||||||||||||||||||||||||
| 108 | E_IDEA(7); executed 14202 times by 1 test: end of blockExecuted by:
executed 6 times by 1 test: x1=(-(int)x1-*p+1);Executed by:
executed 14187 times by 1 test: end of blockExecuted by:
executed 21 times by 1 test: x4=(-(int)x4-*p+1);Executed by:
executed 14142 times by 1 test: end of blockExecuted by:
executed 66 times by 1 test: t0=(-(int)t0-*p+1);Executed by:
executed 14156 times by 1 test: end of blockExecuted by:
executed 52 times by 1 test: t1=(-(int)t1-*p+1);Executed by:
| 6-14202 | ||||||||||||||||||||||||
| 109 | - | |||||||||||||||||||||||||
| 110 | x1 &= 0xffff; | - | ||||||||||||||||||||||||
| 111 | idea_mul(x1, x1, *p, ul); executed 14040 times by 1 test: end of blockExecuted by:
executed 168 times by 1 test: x1=(-(int)x1-*p+1);Executed by:
| 168-14040 | ||||||||||||||||||||||||
| 112 | p++; | - | ||||||||||||||||||||||||
| 113 | - | |||||||||||||||||||||||||
| 114 | t0 = x3 + *(p++); | - | ||||||||||||||||||||||||
| 115 | t1 = x2 + *(p++); | - | ||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||
| 117 | x4 &= 0xffff; | - | ||||||||||||||||||||||||
| 118 | idea_mul(x4, x4, *p, ul); executed 14201 times by 1 test: end of blockExecuted by:
executed 7 times by 1 test: x4=(-(int)x4-*p+1);Executed by:
| 7-14201 | ||||||||||||||||||||||||
| 119 | - | |||||||||||||||||||||||||
| 120 | d[0] = (t0 & 0xffff) | ((x1 & 0xffff) << 16); | - | ||||||||||||||||||||||||
| 121 | d[1] = (x4 & 0xffff) | ((t1 & 0xffff) << 16); | - | ||||||||||||||||||||||||
| 122 | } executed 14208 times by 1 test: end of blockExecuted by:
| 14208 | ||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |