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

Side by Side Diff: nss/lib/softoken/padbuf.c

Issue 2078763002: Delete bundled copy of NSS and replace with README. (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/nss@master
Patch Set: Delete bundled copy of NSS and replace with README. Created 4 years, 6 months 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
« no previous file with comments | « nss/lib/softoken/lowpbe.c ('k') | nss/lib/softoken/pkcs11.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 #include "blapit.h"
5 #include "secport.h"
6 #include "secerr.h"
7
8 /*
9 * Prepare a buffer for any padded CBC encryption algorithm, growing to the
10 * appropriate boundary and filling with the appropriate padding.
11 * blockSize must be a power of 2.
12 *
13 * NOTE: If arena is non-NULL, we re-allocate from there, otherwise
14 * we assume (and use) XP memory (re)allocation.
15 */
16 unsigned char *
17 CBC_PadBuffer(PLArenaPool *arena, unsigned char *inbuf, unsigned int inlen,
18 unsigned int *outlen, int blockSize)
19 {
20 unsigned char *outbuf;
21 unsigned int des_len;
22 unsigned int i;
23 unsigned char des_pad_len;
24
25 /*
26 * We need from 1 to blockSize bytes -- we *always* grow.
27 * The extra bytes contain the value of the length of the padding:
28 * if we have 2 bytes of padding, then the padding is "0x02, 0x02".
29 */
30 des_len = (inlen + blockSize) & ~(blockSize - 1);
31
32 if (arena != NULL) {
33 outbuf = (unsigned char*)PORT_ArenaGrow (arena, inbuf, inlen, des_len);
34 } else {
35 outbuf = (unsigned char*)PORT_Realloc (inbuf, des_len);
36 }
37
38 if (outbuf == NULL) {
39 PORT_SetError (SEC_ERROR_NO_MEMORY);
40 return NULL;
41 }
42
43 des_pad_len = des_len - inlen;
44 for (i = inlen; i < des_len; i++)
45 outbuf[i] = des_pad_len;
46
47 *outlen = des_len;
48 return outbuf;
49 }
OLDNEW
« no previous file with comments | « nss/lib/softoken/lowpbe.c ('k') | nss/lib/softoken/pkcs11.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698