VirtualBox

source: vbox/trunk/src/libs/curl-7.83.1/lib/curl_des.c@ 95312

Last change on this file since 95312 was 95312, checked in by vboxsync, 3 years ago

libs/{curl,libxml2}: OSE export fixes, bugref:8515

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) 2015 - 2022, Steve Holme, <[email protected]>.
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.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_CURL_NTLM_CORE) && !defined(USE_WOLFSSL) && \
26 (defined(USE_GNUTLS) || \
27 defined(USE_NSS) || \
28 defined(USE_SECTRANSP) || \
29 defined(USE_OS400CRYPTO) || \
30 defined(USE_WIN32_CRYPTO))
31
32#include "curl_des.h"
33
34/*
35 * Curl_des_set_odd_parity()
36 *
37 * This is used to apply odd parity to the given byte array. It is typically
38 * used by when a cryptography engines doesn't have it's own version.
39 *
40 * The function is a port of the Java based oddParity() function over at:
41 *
42 * https://davenport.sourceforge.io/ntlm.html
43 *
44 * Parameters:
45 *
46 * bytes [in/out] - The data whose parity bits are to be adjusted for
47 * odd parity.
48 * len [out] - The length of the data.
49 */
50void Curl_des_set_odd_parity(unsigned char *bytes, size_t len)
51{
52 size_t i;
53
54 for(i = 0; i < len; i++) {
55 unsigned char b = bytes[i];
56
57 bool needs_parity = (((b >> 7) ^ (b >> 6) ^ (b >> 5) ^
58 (b >> 4) ^ (b >> 3) ^ (b >> 2) ^
59 (b >> 1)) & 0x01) == 0;
60
61 if(needs_parity)
62 bytes[i] |= 0x01;
63 else
64 bytes[i] &= 0xfe;
65 }
66}
67
68#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette