- Timestamp:
- Feb 7, 2019, 8:36:33 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
asp3_tinet_ecnl_rx/trunk/wolfssl-3.12.2/wolfcrypt/src/coding.c
r337 r372 37 37 BAD = 0xFF, /* invalid encoding */ 38 38 PAD = '=', 39 PEM_LINE_SZ = 64 39 PEM_LINE_SZ = 64, 40 BASE64_MIN = 0x2B, 41 BASE16_MIN = 0x30, 40 42 }; 41 43 … … 60 62 word32 j = 0; 61 63 word32 plainSz = inLen - ((inLen + (PEM_LINE_SZ - 1)) / PEM_LINE_SZ ); 62 const byte maxIdx = (byte)sizeof(base64Decode) + 0x2B- 1;64 const byte maxIdx = (byte)sizeof(base64Decode) + BASE64_MIN - 1; 63 65 64 66 plainSz = (plainSz * 3 + 3) / 4; … … 82 84 pad4 = 1; 83 85 84 if (e1 < 0x2B || e2 < 0x2B || e3 < 0x2B || e4 < 0x2B) {86 if (e1 < BASE64_MIN || e2 < BASE64_MIN || e3 < BASE64_MIN || e4 < BASE64_MIN) { 85 87 WOLFSSL_MSG("Bad Base64 Decode data, too small"); 86 88 return ASN_INPUT_E; … … 92 94 } 93 95 94 e1 = base64Decode[e1 - 0x2B];95 e2 = base64Decode[e2 - 0x2B];96 e3 = (e3 == PAD) ? 0 : base64Decode[e3 - 0x2B];97 e4 = (e4 == PAD) ? 0 : base64Decode[e4 - 0x2B];96 e1 = base64Decode[e1 - BASE64_MIN]; 97 e2 = base64Decode[e2 - BASE64_MIN]; 98 e3 = (e3 == PAD) ? 0 : base64Decode[e3 - BASE64_MIN]; 99 e4 = (e4 == PAD) ? 0 : base64Decode[e4 - BASE64_MIN]; 98 100 99 101 b1 = (byte)((e1 << 2) | (e2 >> 4)); … … 345 347 } 346 348 347 #endif /* defined(WOLFSSL_BASE64_ENCODE) */ 348 349 350 #if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) || defined(HAVE_FIPS) \ 351 || defined(HAVE_ECC_CDH) 349 #endif /* WOLFSSL_BASE64_ENCODE */ 350 351 352 #ifdef WOLFSSL_BASE16 352 353 353 354 static … … 371 372 372 373 if (inLen == 1 && *outLen && in) { 373 byte b = in[inIdx++] - 0x30; /* 0 starts at 0x30 */374 byte b = in[inIdx++] - BASE16_MIN; /* 0 starts at 0x30 */ 374 375 375 376 /* sanity check */ … … 395 396 396 397 while (inLen) { 397 byte b = in[inIdx++] - 0x30; /* 0 starts at 0x30 */398 byte b2 = in[inIdx++] - 0x30;398 byte b = in[inIdx++] - BASE16_MIN; /* 0 starts at 0x30 */ 399 byte b2 = in[inIdx++] - BASE16_MIN; 399 400 400 401 /* sanity checks */ … … 455 456 } 456 457 457 #endif /* (OPENSSL_EXTRA) || (HAVE_WEBSERVER) || (HAVE_FIPS)*/458 459 #endif /* NO_CODING */458 #endif /* WOLFSSL_BASE16 */ 459 460 #endif /* !NO_CODING */
Note:
See TracChangeset
for help on using the changeset viewer.