| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/des/ofb_enc.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 "des_locl.h" | - | ||||||
| 11 | - | |||||||
| 12 | /* | - | ||||||
| 13 | * The input and output are loaded in multiples of 8 bits. What this means is | - | ||||||
| 14 | * that if you have numbits=12 and length=2 the first 12 bits will be | - | ||||||
| 15 | * retrieved from the first byte and half the second. The second 12 bits | - | ||||||
| 16 | * will come from the 3rd and half the 4th byte. | - | ||||||
| 17 | */ | - | ||||||
| 18 | void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | - | ||||||
| 19 | long length, DES_key_schedule *schedule, | - | ||||||
| 20 | DES_cblock *ivec) | - | ||||||
| 21 | { | - | ||||||
| 22 | register DES_LONG d0, d1, vv0, vv1, v0, v1, n = (numbits + 7) / 8; | - | ||||||
| 23 | register DES_LONG mask0, mask1; | - | ||||||
| 24 | register long l = length; | - | ||||||
| 25 | register int num = numbits; | - | ||||||
| 26 | DES_LONG ti[2]; | - | ||||||
| 27 | unsigned char *iv; | - | ||||||
| 28 | - | |||||||
| 29 | if (num > 64)
| 0-2 | ||||||
| 30 | return; never executed: return; | 0 | ||||||
| 31 | if (num > 32) {
| 0-2 | ||||||
| 32 | mask0 = 0xffffffffL; | - | ||||||
| 33 | if (num >= 64)
| 0-2 | ||||||
| 34 | mask1 = mask0; executed 2 times by 1 test: mask1 = mask0;Executed by:
| 2 | ||||||
| 35 | else | - | ||||||
| 36 | mask1 = (1L << (num - 32)) - 1; never executed: mask1 = (1L << (num - 32)) - 1; | 0 | ||||||
| 37 | } else { | - | ||||||
| 38 | if (num == 32)
| 0 | ||||||
| 39 | mask0 = 0xffffffffL; never executed: mask0 = 0xffffffffL; | 0 | ||||||
| 40 | else | - | ||||||
| 41 | mask0 = (1L << num) - 1; never executed: mask0 = (1L << num) - 1; | 0 | ||||||
| 42 | mask1 = 0x00000000L; | - | ||||||
| 43 | } never executed: end of block | 0 | ||||||
| 44 | - | |||||||
| 45 | iv = &(*ivec)[0]; | - | ||||||
| 46 | c2l(iv, v0); | - | ||||||
| 47 | c2l(iv, v1); | - | ||||||
| 48 | ti[0] = v0; | - | ||||||
| 49 | ti[1] = v1; | - | ||||||
| 50 | while (l-- > 0) {
| 2-6 | ||||||
| 51 | ti[0] = v0; | - | ||||||
| 52 | ti[1] = v1; | - | ||||||
| 53 | DES_encrypt1((DES_LONG *)ti, schedule, DES_ENCRYPT); | - | ||||||
| 54 | vv0 = ti[0]; | - | ||||||
| 55 | vv1 = ti[1]; | - | ||||||
| 56 | c2ln(in, d0, d1, n); executed 6 times by 1 test: end of blockExecuted by:
code before this statement executed 6 times by 1 test: case 7:Executed by:
code before this statement executed 6 times by 1 test: case 6:Executed by:
code before this statement executed 6 times by 1 test: case 5:Executed by:
code before this statement executed 6 times by 1 test: case 4:Executed by:
code before this statement executed 6 times by 1 test: case 3:Executed by:
code before this statement executed 6 times by 1 test: case 2:Executed by:
code before this statement executed 6 times by 1 test: case 1:Executed by:
executed 6 times by 1 test: case 8:Executed by:
never executed: case 7:never executed: case 6:never executed: case 5:never executed: case 4:never executed: case 3:never executed: case 2:executed 6 times by 1 test: case 1:Executed by:
| 0-6 | ||||||
| 57 | in += n; | - | ||||||
| 58 | d0 = (d0 ^ vv0) & mask0; | - | ||||||
| 59 | d1 = (d1 ^ vv1) & mask1; | - | ||||||
| 60 | l2cn(d0, d1, out, n); executed 6 times by 1 test: end of blockExecuted by:
code before this statement executed 6 times by 1 test: case 7:Executed by:
code before this statement executed 6 times by 1 test: case 6:Executed by:
code before this statement executed 6 times by 1 test: case 5:Executed by:
code before this statement executed 6 times by 1 test: case 4:Executed by:
code before this statement executed 6 times by 1 test: case 3:Executed by:
code before this statement executed 6 times by 1 test: case 2:Executed by:
code before this statement executed 6 times by 1 test: case 1:Executed by:
executed 6 times by 1 test: case 8:Executed by:
never executed: case 7:never executed: case 6:never executed: case 5:never executed: case 4:never executed: case 3:never executed: case 2:executed 6 times by 1 test: case 1:Executed by:
| 0-6 | ||||||
| 61 | out += n; | - | ||||||
| 62 | - | |||||||
| 63 | if (num == 32) {
| 0-6 | ||||||
| 64 | v0 = v1; | - | ||||||
| 65 | v1 = vv0; | - | ||||||
| 66 | } else if (num == 64) { never executed: end of block
| 0-6 | ||||||
| 67 | v0 = vv0; | - | ||||||
| 68 | v1 = vv1; | - | ||||||
| 69 | } else if (num > 32) { /* && num != 64 */ executed 6 times by 1 test: end of blockExecuted by:
| 0-6 | ||||||
| 70 | v0 = ((v1 >> (num - 32)) | (vv0 << (64 - num))) & 0xffffffffL; | - | ||||||
| 71 | v1 = ((vv0 >> (num - 32)) | (vv1 << (64 - num))) & 0xffffffffL; | - | ||||||
| 72 | } else { /* num < 32 */ never executed: end of block | 0 | ||||||
| 73 | - | |||||||
| 74 | v0 = ((v0 >> num) | (v1 << (32 - num))) & 0xffffffffL; | - | ||||||
| 75 | v1 = ((v1 >> num) | (vv0 << (32 - num))) & 0xffffffffL; | - | ||||||
| 76 | } never executed: end of block | 0 | ||||||
| 77 | } | - | ||||||
| 78 | iv = &(*ivec)[0]; | - | ||||||
| 79 | l2c(v0, iv); | - | ||||||
| 80 | l2c(v1, iv); | - | ||||||
| 81 | v0 = v1 = d0 = d1 = ti[0] = ti[1] = vv0 = vv1 = 0; | - | ||||||
| 82 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||
| Source code | Switch to Preprocessed file |