source: asp3_tinet_ecnl_arm/trunk/curl-7.57.0/lib/curl_des.c@ 352

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

arm向けASP3版ECNLを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc;charset=UTF-8
File size: 2.0 KB
Line 
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) 2015, Steve Holme, <steve_holme@hotmail.com>.
9 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.haxx.se/docs/copyright.html.
13 *
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 ***************************************************************************/
22
23#include "curl_setup.h"
24
25#if defined(USE_NTLM) && !defined(USE_OPENSSL)
26
27#include "curl_des.h"
28
29/*
30 * Curl_des_set_odd_parity()
31 *
32 * This is used to apply odd parity to the given byte array. It is typically
33 * used by when a cryptography engines doesn't have it's own version.
34 *
35 * The function is a port of the Java based oddParity() function over at:
36 *
37 * https://davenport.sourceforge.io/ntlm.html
38 *
39 * Parameters:
40 *
41 * bytes [in/out] - The data whose parity bits are to be adjusted for
42 * odd parity.
43 * len [out] - The length of the data.
44 */
45void Curl_des_set_odd_parity(unsigned char *bytes, size_t len)
46{
47 size_t i;
48
49 for(i = 0; i < len; i++) {
50 unsigned char b = bytes[i];
51
52 bool needs_parity = (((b >> 7) ^ (b >> 6) ^ (b >> 5) ^
53 (b >> 4) ^ (b >> 3) ^ (b >> 2) ^
54 (b >> 1)) & 0x01) == 0;
55
56 if(needs_parity)
57 bytes[i] |= 0x01;
58 else
59 bytes[i] &= 0xfe;
60 }
61}
62
63#endif /* USE_NTLM && !USE_OPENSSL */
Note: See TracBrowser for help on using the repository browser.