| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/des/qud_cksm.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 | /* | - | ||||||||||||
| 11 | * From "Message Authentication" R.R. Jueneman, S.M. Matyas, C.H. Meyer IEEE | - | ||||||||||||
| 12 | * Communications Magazine Sept 1985 Vol. 23 No. 9 p 29-40 This module in | - | ||||||||||||
| 13 | * only based on the code in this paper and is almost definitely not the same | - | ||||||||||||
| 14 | * as the MIT implementation. | - | ||||||||||||
| 15 | */ | - | ||||||||||||
| 16 | #include "des_locl.h" | - | ||||||||||||
| 17 | - | |||||||||||||
| 18 | #define Q_B0(a) (((DES_LONG)(a))) | - | ||||||||||||
| 19 | #define Q_B1(a) (((DES_LONG)(a))<<8) | - | ||||||||||||
| 20 | #define Q_B2(a) (((DES_LONG)(a))<<16) | - | ||||||||||||
| 21 | #define Q_B3(a) (((DES_LONG)(a))<<24) | - | ||||||||||||
| 22 | - | |||||||||||||
| 23 | /* used to scramble things a bit */ | - | ||||||||||||
| 24 | /* Got the value MIT uses via brute force :-) 2/10/90 eay */ | - | ||||||||||||
| 25 | #define NOISE ((DES_LONG)83653421L) | - | ||||||||||||
| 26 | - | |||||||||||||
| 27 | DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[], | - | ||||||||||||
| 28 | long length, int out_count, DES_cblock *seed) | - | ||||||||||||
| 29 | { | - | ||||||||||||
| 30 | DES_LONG z0, z1, t0, t1; | - | ||||||||||||
| 31 | int i; | - | ||||||||||||
| 32 | long l; | - | ||||||||||||
| 33 | const unsigned char *cp; | - | ||||||||||||
| 34 | DES_LONG *lp; | - | ||||||||||||
| 35 | - | |||||||||||||
| 36 | if (out_count < 1)
| 0-1 | ||||||||||||
| 37 | out_count = 1; never executed: out_count = 1; | 0 | ||||||||||||
| 38 | lp = (DES_LONG *)&(output[0])[0]; | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | z0 = Q_B0((*seed)[0]) | Q_B1((*seed)[1]) | Q_B2((*seed)[2]) | | - | ||||||||||||
| 41 | Q_B3((*seed)[3]); | - | ||||||||||||
| 42 | z1 = Q_B0((*seed)[4]) | Q_B1((*seed)[5]) | Q_B2((*seed)[6]) | | - | ||||||||||||
| 43 | Q_B3((*seed)[7]); | - | ||||||||||||
| 44 | - | |||||||||||||
| 45 | for (i = 0; ((i < 4) && (i < out_count)); i++) {
| 0-3 | ||||||||||||
| 46 | cp = input; | - | ||||||||||||
| 47 | l = length; | - | ||||||||||||
| 48 | while (l > 0) {
| 2-28 | ||||||||||||
| 49 | if (l > 1) {
| 0-28 | ||||||||||||
| 50 | t0 = (DES_LONG)(*(cp++)); | - | ||||||||||||
| 51 | t0 |= (DES_LONG)Q_B1(*(cp++)); | - | ||||||||||||
| 52 | l--; | - | ||||||||||||
| 53 | } else executed 28 times by 1 test: end of blockExecuted by:
| 28 | ||||||||||||
| 54 | t0 = (DES_LONG)(*(cp++)); never executed: t0 = (DES_LONG)(*(cp++)); | 0 | ||||||||||||
| 55 | l--; | - | ||||||||||||
| 56 | /* add */ | - | ||||||||||||
| 57 | t0 += z0; | - | ||||||||||||
| 58 | t0 &= 0xffffffffL; | - | ||||||||||||
| 59 | t1 = z1; | - | ||||||||||||
| 60 | /* square, well sort of square */ | - | ||||||||||||
| 61 | z0 = ((((t0 * t0) & 0xffffffffL) + ((t1 * t1) & 0xffffffffL)) | - | ||||||||||||
| 62 | & 0xffffffffL) % 0x7fffffffL; | - | ||||||||||||
| 63 | z1 = ((t0 * ((t1 + NOISE) & 0xffffffffL)) & 0xffffffffL) % | - | ||||||||||||
| 64 | 0x7fffffffL; | - | ||||||||||||
| 65 | } executed 28 times by 1 test: end of blockExecuted by:
| 28 | ||||||||||||
| 66 | if (lp != NULL) {
| 0-2 | ||||||||||||
| 67 | /* | - | ||||||||||||
| 68 | * The MIT library assumes that the checksum is composed of | - | ||||||||||||
| 69 | * 2*out_count 32 bit ints | - | ||||||||||||
| 70 | */ | - | ||||||||||||
| 71 | *lp++ = z0; | - | ||||||||||||
| 72 | *lp++ = z1; | - | ||||||||||||
| 73 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||
| 74 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||
| 75 | return z0; executed 1 time by 1 test: return z0;Executed by:
| 1 | ||||||||||||
| 76 | } | - | ||||||||||||
| Source code | Switch to Preprocessed file |