Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(474)

Side by Side Diff: nss/lib/freebl/desblapi.c

Issue 1504923011: Update NSS to 3.21 RTM and NSPR to 4.11 RTM (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/nss
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * desblapi.c 2 * desblapi.c
3 * 3 *
4 * core source file for DES-150 library 4 * core source file for DES-150 library
5 * Implement DES Modes of Operation and Triple-DES. 5 * Implement DES Modes of Operation and Triple-DES.
6 * Adapt DES-150 to blapi API. 6 * Adapt DES-150 to blapi API.
7 * 7 *
8 * This Source Code Form is subject to the terms of the Mozilla Public 8 * This Source Code Form is subject to the terms of the Mozilla Public
9 * License, v. 2.0. If a copy of the MPL was not distributed with this 9 * License, v. 2.0. If a copy of the MPL was not distributed with this
10 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 10 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
11 11
12 #ifdef FREEBL_NO_DEPEND 12 #ifdef FREEBL_NO_DEPEND
13 #include "stubs.h" 13 #include "stubs.h"
14 #endif 14 #endif
15 15
16 #include "des.h" 16 #include "des.h"
17 #include <stddef.h> 17 #include <stddef.h>
18 #include "secerr.h" 18 #include "secerr.h"
19 19
20 #if defined(NSS_X86_OR_X64) 20 #if defined(NSS_X86_OR_X64)
21 /* Intel X86 CPUs do unaligned loads and stores without complaint. */ 21 /* Intel X86 CPUs do unaligned loads and stores without complaint. */
22 #define COPY8B(to, from, ptr) \ 22 #define COPY8B(to, from, ptr) \
23 HALFPTR(to)[0] = HALFPTR(from)[0]; \ 23 HALFPTR(to)[0] = HALFPTR(from)[0]; \
24 HALFPTR(to)[1] = HALFPTR(from)[1]; 24 HALFPTR(to)[1] = HALFPTR(from)[1];
25 #elif defined(USE_MEMCPY) 25 #else
26 #define COPY8B(to, from, ptr) memcpy(to, from, 8) 26 #define COPY8B(to, from, ptr) memcpy(to, from, 8)
27 #else
28 #define COPY8B(to, from, ptr) \
29 if (((ptrdiff_t)(ptr) & 0x3) == 0) { \
30 HALFPTR(to)[0] = HALFPTR(from)[0]; \
31 HALFPTR(to)[1] = HALFPTR(from)[1]; \
32 } else if (((ptrdiff_t)(ptr) & 0x1) == 0) { \
33 SHORTPTR(to)[0] = SHORTPTR(from)[0]; \
34 SHORTPTR(to)[1] = SHORTPTR(from)[1]; \
35 SHORTPTR(to)[2] = SHORTPTR(from)[2]; \
36 SHORTPTR(to)[3] = SHORTPTR(from)[3]; \
37 } else { \
38 BYTEPTR(to)[0] = BYTEPTR(from)[0]; \
39 BYTEPTR(to)[1] = BYTEPTR(from)[1]; \
40 BYTEPTR(to)[2] = BYTEPTR(from)[2]; \
41 BYTEPTR(to)[3] = BYTEPTR(from)[3]; \
42 BYTEPTR(to)[4] = BYTEPTR(from)[4]; \
43 BYTEPTR(to)[5] = BYTEPTR(from)[5]; \
44 BYTEPTR(to)[6] = BYTEPTR(from)[6]; \
45 BYTEPTR(to)[7] = BYTEPTR(from)[7]; \
46 }
47 #endif 27 #endif
48 #define COPY8BTOHALF(to, from) COPY8B(to, from, from) 28 #define COPY8BTOHALF(to, from) COPY8B(to, from, from)
49 #define COPY8BFROMHALF(to, from) COPY8B(to, from, to) 29 #define COPY8BFROMHALF(to, from) COPY8B(to, from, to)
50 30
51 static void 31 static void
52 DES_ECB(DESContext *cx, BYTE *out, const BYTE *in, unsigned int len) 32 DES_ECB(DESContext *cx, BYTE *out, const BYTE *in, unsigned int len)
53 { 33 {
54 while (len) { 34 while (len) {
55 DES_Do1Block(cx->ks0, in, out); 35 DES_Do1Block(cx->ks0, in, out);
56 len -= 8; 36 len -= 8;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 cx->direction != DES_DECRYPT) { 244 cx->direction != DES_DECRYPT) {
265 PORT_SetError(SEC_ERROR_INVALID_ARGS); 245 PORT_SetError(SEC_ERROR_INVALID_ARGS);
266 return SECFailure; 246 return SECFailure;
267 } 247 }
268 248
269 cx->worker(cx, out, in, inLen); 249 cx->worker(cx, out, in, inLen);
270 if (outLen) 250 if (outLen)
271 *outLen = inLen; 251 *outLen = inLen;
272 return SECSuccess; 252 return SECSuccess;
273 } 253 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698