source: EcnlProtoTool/trunk/openssl-1.1.0e/crypto/des/qud_cksm.c@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc
File size: 2.4 KB
Line 
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/* bug fix for dos - 7/6/91 - Larry hughes@logos.ucs.indiana.edu */
19#define Q_B0(a) (((DES_LONG)(a)))
20#define Q_B1(a) (((DES_LONG)(a))<<8)
21#define Q_B2(a) (((DES_LONG)(a))<<16)
22#define Q_B3(a) (((DES_LONG)(a))<<24)
23
24/* used to scramble things a bit */
25/* Got the value MIT uses via brute force :-) 2/10/90 eay */
26#define NOISE ((DES_LONG)83653421L)
27
28DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[],
29 long length, int out_count, DES_cblock *seed)
30{
31 DES_LONG z0, z1, t0, t1;
32 int i;
33 long l;
34 const unsigned char *cp;
35 DES_LONG *lp;
36
37 if (out_count < 1)
38 out_count = 1;
39 lp = (DES_LONG *)&(output[0])[0];
40
41 z0 = Q_B0((*seed)[0]) | Q_B1((*seed)[1]) | Q_B2((*seed)[2]) |
42 Q_B3((*seed)[3]);
43 z1 = Q_B0((*seed)[4]) | Q_B1((*seed)[5]) | Q_B2((*seed)[6]) |
44 Q_B3((*seed)[7]);
45
46 for (i = 0; ((i < 4) && (i < out_count)); i++) {
47 cp = input;
48 l = length;
49 while (l > 0) {
50 if (l > 1) {
51 t0 = (DES_LONG)(*(cp++));
52 t0 |= (DES_LONG)Q_B1(*(cp++));
53 l--;
54 } else
55 t0 = (DES_LONG)(*(cp++));
56 l--;
57 /* add */
58 t0 += z0;
59 t0 &= 0xffffffffL;
60 t1 = z1;
61 /* square, well sort of square */
62 z0 = ((((t0 * t0) & 0xffffffffL) + ((t1 * t1) & 0xffffffffL))
63 & 0xffffffffL) % 0x7fffffffL;
64 z1 = ((t0 * ((t1 + NOISE) & 0xffffffffL)) & 0xffffffffL) %
65 0x7fffffffL;
66 }
67 if (lp != NULL) {
68 /*
69 * The MIT library assumes that the checksum is composed of
70 * 2*out_count 32 bit ints
71 */
72 *lp++ = z0;
73 *lp++ = z1;
74 }
75 }
76 return (z0);
77}
Note: See TracBrowser for help on using the repository browser.