MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / base64decode

Function base64decode

ut.c:458–513  ·  view source on GitHub ↗

function that decodes from base64 * output buffer is assumed to have the right length */

Source from the content-addressed store, hash-verified

456/* function that decodes from base64
457 * output buffer is assumed to have the right length */
458int base64decode(unsigned char *out, unsigned char *in, int len)
459{
460 int i=0;
461 unsigned char c1,c2,c3,c4;
462 int out_len=0;
463
464 while (len > i)
465 {
466 do
467 {
468 c1 = base64val[in[i++]];
469 } while (i<len && c1 == BAD);
470
471 if (c1 == BAD)
472 break;
473
474 do
475 {
476 c2 = base64val[in[i++]];
477 } while (i<len && c2 == BAD);
478
479 if (c2 == BAD)
480 break;
481
482 out[out_len++] = (c1 << 2) | ((c2 & 0x30) >> 4);
483
484 do
485 {
486 c3 = in[i++];
487 if (c3 == 61)
488 return out_len;
489
490 c3 = base64val[c3];
491 } while (i<len && c3 == BAD);
492
493 if (c3 == BAD)
494 break;
495
496 out[out_len++] = ((c2 & 0x0f) << 4) | ((c3 & 0x3c) >> 2);
497
498 do
499 {
500 c4 = in[i++];
501 if (c4 == 61)
502 return out_len;
503 c4 = base64val[c4];
504 } while (i<len && c4 == BAD);
505
506 if (c4 == BAD)
507 break;
508
509 out[out_len++] = ((c3 & 0x03) << 6) | c4;
510 }
511
512 return out_len;
513}
514
515/* function that decodes from base64URL

Callers 8

tr_eval_stringFunction · 0.85
deserialize_he_rdataFunction · 0.85
deserialize_dns_rdataFunction · 0.85
aka_build_resyncFunction · 0.85
restore_nated_ruri_fFunction · 0.85
mc_decompressFunction · 0.85
cdb_val_decodeFunction · 0.85
extract_aorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected