/*@-internalglobs -modfilesys @*/
int b64decode (const char * s, void ** datap, int *lenp)
{
- unsigned char b64dec[255];
+ unsigned char b64dec[256];
const unsigned char *t;
unsigned char *te;
int ns, nt;
for (t = s; *t != '\0'; t++) {
switch (b64dec[ (unsigned)*t ]) {
case 0x80: /* invalid chararcter */
+fprintf(stderr, "--- b64decode %c(%02x) %02x\n", *t, (*t & 0xff), b64dec[ (unsigned)*t ]);
return 3;
/*@notreached@*/ /*@switchbreak@*/ break;
case 0x81: /* white space */
if (ns != 0) { /* XXX can't happen, just in case */
if (t) free((void *)t);
- return 3;
+ return 1;
}
if (lenp)
*lenp = (te - t);
}
/*@=nullstate =compdef @*/
-/*@-nullstate -compdef @*/ /* b->modl may be null @*/
-void mp32bswabhex(mp32barrett* b, const char* hex)
-{
- uint32 length = strlen(hex);
- uint32 size = (length+7) >> 3;
- uint8 rem = (uint8)(length & 0x7);
-
- if (b->modl)
- {
- if (b->size != size)
- b->modl = (uint32*) realloc(b->modl, (2*size+1) * sizeof(uint32));
- }
- else
- b->modl = (uint32*) malloc((2*size+1) * sizeof(uint32));
-
- if (b->modl != (uint32*) 0)
- {
- register uint32 val = 0;
- register uint32* dst = b->modl;
- register uint32* temp = (uint32*) malloc((6*size+4) * sizeof(uint32));
- register char ch;
-
- b->size = size;
- b->mu = b->modl+size;
-
- while (length-- > 0)
- {
- ch = *(hex++);
- val <<= 4;
- if (ch >= '0' && ch <= '9')
- val += (ch - '0');
- else if (ch >= 'A' && ch <= 'F')
- val += (ch - 'A') + 10;
- else if (ch >= 'a' && ch <= 'f')
- val += (ch - 'a') + 10;
- else
- {};
-
- if ((length & 0x7) == 0)
- {
- *(dst++) = swapu32(val);
- val = 0;
- }
- }
- if (rem != 0)
- *dst = swapu32(val);
-
- /*@-nullpass@*/ /* temp may be NULL */
- mp32bmu_w(b, temp);
-
- free(temp);
- /*@=nullpass@*/
- }
- else
- {
- b->size = 0;
- b->mu = 0;
- }
-}
-/*@=nullstate =compdef @*/
-
/**
* Computes the Barrett 'mu' coefficient.
* needs workspace of (6*size+4) words
/**
*/
-BEEDLLAPI /*@unused@*/
-void mp32bswabhex(mp32barrett* b, const char* hex)
- /*@modifies b->size, b->modl, b->mu @*/;
-
-/**
- */
BEEDLLAPI
void mp32bsubone(const mp32barrett* b, uint32* result)
/*@modifies result @*/;
}
}
/*@=nullstate =compdef @*/
-
-/*@-nullstate -compdef @*/ /* n->data may be NULL */
-void mp32nswabhex(mp32number* n, const char* hex)
-{
- uint32 length = strlen(hex);
- uint32 size = (length+7) >> 3;
- uint8 rem = (uint8)(length & 0x7);
-
- if (n->data)
- {
- if (n->size != size)
- n->data = (uint32*) realloc(n->data, size * sizeof(uint32));
- }
- else
- n->data = (uint32*) malloc(size * sizeof(uint32));
-
- if (n->data)
- {
- register uint32 val = 0;
- register uint32* dst = n->data;
- register char ch;
-
- n->size = size;
-
- while (length-- > 0)
- {
- ch = *(hex++);
- val <<= 4;
- if (ch >= '0' && ch <= '9')
- val += (ch - '0');
- else if (ch >= 'A' && ch <= 'F')
- val += (ch - 'A') + 10;
- else if (ch >= 'a' && ch <= 'f')
- val += (ch - 'a') + 10;
- else
- {};
-
- if ((length & 0x7) == 0)
- {
- *(dst++) = swapu32(val);
- val = 0;
- }
- }
- if (rem != 0)
- *dst = swapu32(val);
- }
- else {
- n->size = 0;
- n->data = (uint32*)0;
- }
-}
-/*@=nullstate =compdef @*/
void mp32nsethex(mp32number* n, const char* hex)
/*@modifies n->size, n->data @*/;
-/**
- */
-BEEDLLAPI /*@unused@*/
-void mp32nswabhex(mp32number* n, const char* hex)
- /*@modifies n->size, n->data @*/;
-
#ifdef __cplusplus
}
#endif