OLD | NEW |
1 /* | 1 /* |
2 * datatypes.c | 2 * datatypes.c |
3 * | 3 * |
4 * data types for finite fields and functions for input, output, and | 4 * data types for finite fields and functions for input, output, and |
5 * manipulation | 5 * manipulation |
6 * | 6 * |
7 * David A. McGrew | 7 * David A. McGrew |
8 * Cisco Systems, Inc. | 8 * Cisco Systems, Inc. |
9 */ | 9 */ |
10 /* | 10 /* |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 } while (++s < end); | 528 } while (++s < end); |
529 | 529 |
530 } | 530 } |
531 | 531 |
532 #ifdef TESTAPP_SOURCE | 532 #ifdef TESTAPP_SOURCE |
533 | 533 |
534 static const char b64chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | 534 static const char b64chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
535 "abcdefghijklmnopqrstuvwxyz0123456789+/"; | 535 "abcdefghijklmnopqrstuvwxyz0123456789+/"; |
536 | 536 |
537 static int base64_block_to_octet_triple(char *out, char *in) { | 537 static int base64_block_to_octet_triple(char *out, char *in) { |
538 unsigned char sextets[4] = {}; | 538 unsigned char sextets[4] = {0}; |
539 int j = 0; | 539 int j = 0; |
540 int i; | 540 int i; |
541 | 541 |
542 for (i = 0; i < 4; i++) { | 542 for (i = 0; i < 4; i++) { |
543 char *p = strchr(b64chars, in[i]); | 543 char *p = strchr(b64chars, in[i]); |
544 if (p != NULL) sextets[i] = p - b64chars; | 544 if (p != NULL) sextets[i] = p - b64chars; |
545 else j++; | 545 else j++; |
546 } | 546 } |
547 | 547 |
548 out[0] = (sextets[0]<<2)|(sextets[1]>>4); | 548 out[0] = (sextets[0]<<2)|(sextets[1]>>4); |
(...skipping 11 matching lines...) Expand all Loading... |
560 while (i < len && j == 0) { | 560 while (i < len && j == 0) { |
561 j = base64_block_to_octet_triple(out + k, in + i); | 561 j = base64_block_to_octet_triple(out + k, in + i); |
562 k += 3; | 562 k += 3; |
563 i += 4; | 563 i += 4; |
564 } | 564 } |
565 *pad = j; | 565 *pad = j; |
566 return i; | 566 return i; |
567 } | 567 } |
568 | 568 |
569 #endif | 569 #endif |
OLD | NEW |