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 25 matching lines...) Expand all Loading... |
36 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 36 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
38 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 38 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
41 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 41 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
42 * OF THE POSSIBILITY OF SUCH DAMAGE. | 42 * OF THE POSSIBILITY OF SUCH DAMAGE. |
43 * | 43 * |
44 */ | 44 */ |
45 | 45 |
| 46 #ifdef HAVE_CONFIG_H |
| 47 #include <config.h> |
| 48 #endif |
| 49 |
46 #include "datatypes.h" | 50 #include "datatypes.h" |
47 | 51 |
48 int | 52 int |
49 octet_weight[256] = { | 53 octet_weight[256] = { |
50 0, 1, 1, 2, 1, 2, 2, 3, | 54 0, 1, 1, 2, 1, 2, 2, 3, |
51 1, 2, 2, 3, 2, 3, 3, 4, | 55 1, 2, 2, 3, 2, 3, 3, 4, |
52 1, 2, 2, 3, 2, 3, 3, 4, | 56 1, 2, 2, 3, 2, 3, 3, 4, |
53 2, 3, 3, 4, 3, 4, 4, 5, | 57 2, 3, 3, 4, 3, 4, 4, 5, |
54 1, 2, 2, 3, 2, 3, 3, 4, | 58 1, 2, 2, 3, 2, 3, 3, 4, |
55 2, 3, 3, 4, 3, 4, 4, 5, | 59 2, 3, 3, 4, 3, 4, 4, 5, |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 case '/': | 685 case '/': |
682 return 63; | 686 return 63; |
683 case '=': | 687 case '=': |
684 return 64; | 688 return 64; |
685 default: | 689 default: |
686 break; | 690 break; |
687 } | 691 } |
688 return -1; | 692 return -1; |
689 } | 693 } |
690 | 694 |
| 695 #ifdef INCLUDE_DEAD_CODE |
691 /* | 696 /* |
692 * base64_string_to_octet_string converts a hexadecimal string | 697 * base64_string_to_octet_string converts a hexadecimal string |
693 * of length 2 * len to a raw octet string of length len | 698 * of length 2 * len to a raw octet string of length len |
694 */ | 699 */ |
695 | 700 |
696 int | 701 int |
697 base64_string_to_octet_string(char *raw, char *base64, int len) { | 702 base64_string_to_octet_string(char *raw, char *base64, int len) { |
698 uint8_t x; | 703 uint8_t x; |
699 int tmp; | 704 int tmp; |
700 int base64_len; | 705 int base64_len; |
701 | 706 |
702 base64_len = 0; | 707 base64_len = 0; |
703 while (base64_len < len) { | 708 while (base64_len < len) { |
704 tmp = base64_char_to_sextet(base64[0]); | 709 tmp = base64_char_to_sextet(base64[0]); |
705 if (tmp == -1) | 710 if (tmp == -1) |
706 return base64_len; | 711 return base64_len; |
707 x = (tmp << 6); | 712 x = (tmp << 6); |
708 base64_len++; | 713 base64_len++; |
709 tmp = base64_char_to_sextet(base64[1]); | 714 tmp = base64_char_to_sextet(base64[1]); |
710 if (tmp == -1) | 715 if (tmp == -1) |
711 return base64_len; | 716 return base64_len; |
712 x |= (tmp & 0xffff); | 717 x |= (tmp & 0xffff); |
713 base64_len++; | 718 base64_len++; |
714 *raw++ = x; | 719 *raw++ = x; |
715 base64 += 2; | 720 base64 += 2; |
716 } | 721 } |
717 return base64_len; | 722 return base64_len; |
718 } | 723 } |
| 724 #endif |
OLD | NEW |