| OLD | NEW |
| 1 /* x_long.c */ | 1 /* x_long.c */ |
| 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 * project 2000. | 3 * project 2000. |
| 4 */ | 4 */ |
| 5 /* ==================================================================== | 5 /* ==================================================================== |
| 6 * Copyright (c) 2000 The OpenSSL Project. All rights reserved. | 6 * Copyright (c) 2000 The OpenSSL Project. All rights reserved. |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 /* Custom primitive type for long handling. This converts between an ASN1_INTEGE
R | 64 /* Custom primitive type for long handling. This converts between an ASN1_INTEGE
R |
| 65 * and a long directly. | 65 * and a long directly. |
| 66 */ | 66 */ |
| 67 | 67 |
| 68 | 68 |
| 69 static int long_new(ASN1_VALUE **pval, const ASN1_ITEM *it); | 69 static int long_new(ASN1_VALUE **pval, const ASN1_ITEM *it); |
| 70 static void long_free(ASN1_VALUE **pval, const ASN1_ITEM *it); | 70 static void long_free(ASN1_VALUE **pval, const ASN1_ITEM *it); |
| 71 | 71 |
| 72 static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const A
SN1_ITEM *it); | 72 static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const A
SN1_ITEM *it); |
| 73 static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int u
type, char *free_cont, const ASN1_ITEM *it); | 73 static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int u
type, char *free_cont, const ASN1_ITEM *it); |
| 74 static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int inde
nt, const ASN1_PCTX *pctx); |
| 74 | 75 |
| 75 static ASN1_PRIMITIVE_FUNCS long_pf = { | 76 static ASN1_PRIMITIVE_FUNCS long_pf = { |
| 76 NULL, 0, | 77 NULL, 0, |
| 77 long_new, | 78 long_new, |
| 78 long_free, | 79 long_free, |
| 79 long_free, /* Clear should set to initial value */ | 80 long_free, /* Clear should set to initial value */ |
| 80 long_c2i, | 81 long_c2i, |
| 81 » long_i2c | 82 » long_i2c, |
| 83 » long_print |
| 82 }; | 84 }; |
| 83 | 85 |
| 84 ASN1_ITEM_start(LONG) | 86 ASN1_ITEM_start(LONG) |
| 85 ASN1_ITYPE_PRIMITIVE, V_ASN1_INTEGER, NULL, 0, &long_pf, ASN1_LONG_UNDEF
, "LONG" | 87 ASN1_ITYPE_PRIMITIVE, V_ASN1_INTEGER, NULL, 0, &long_pf, ASN1_LONG_UNDEF
, "LONG" |
| 86 ASN1_ITEM_end(LONG) | 88 ASN1_ITEM_end(LONG) |
| 87 | 89 |
| 88 ASN1_ITEM_start(ZLONG) | 90 ASN1_ITEM_start(ZLONG) |
| 89 ASN1_ITYPE_PRIMITIVE, V_ASN1_INTEGER, NULL, 0, &long_pf, 0, "ZLONG" | 91 ASN1_ITYPE_PRIMITIVE, V_ASN1_INTEGER, NULL, 0, &long_pf, 0, "ZLONG" |
| 90 ASN1_ITEM_end(ZLONG) | 92 ASN1_ITEM_end(ZLONG) |
| 91 | 93 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 ltmp++; | 164 ltmp++; |
| 163 ltmp = -ltmp; | 165 ltmp = -ltmp; |
| 164 } | 166 } |
| 165 if(ltmp == it->size) { | 167 if(ltmp == it->size) { |
| 166 ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG); | 168 ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG); |
| 167 return 0; | 169 return 0; |
| 168 } | 170 } |
| 169 memcpy(cp, <mp, sizeof(long)); | 171 memcpy(cp, <mp, sizeof(long)); |
| 170 return 1; | 172 return 1; |
| 171 } | 173 } |
| 174 |
| 175 static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, |
| 176 int indent, const ASN1_PCTX *pctx) |
| 177 { |
| 178 return BIO_printf(out, "%ld\n", *(long *)pval); |
| 179 } |
| OLD | NEW |