MCPcopy Index your code
hub / github.com/MapServer/MapServer / main

Function main

mapcrypto.c:522–629  ·  view source on GitHub ↗

Test for mapcrypto.c functions. To run these tests, use the following ** Makefile directive: test_mapcrypto: $(LIBMAP_STATIC) mapcrypto.c $(CC) $(CFLAGS) mapcrypto.c -DTEST_MAPCRYPTO $(EXE_LDFLAGS) -o test_mapcrypto ** */

Source from the content-addressed store, hash-verified

520**
521*/
522int main(int argc, char *argv[])
523{
524 const unsigned char bytes_in[] = {0x12, 0x34, 0xff, 0x00, 0x44, 0x22};
525 unsigned char bytes_out[8], encryption_key[MS_ENCRYPTION_KEY_SIZE*2+1];
526 char string_buf[256], string_buf2[256];
527 int numbytes = 0;
528
529 /*
530 ** Test msHexEncode()
531 */
532 msHexEncode(bytes_in, string_buf, 6);
533 printf("msHexEncode returned '%s'\n", string_buf);
534
535 /*
536 ** Test msHexDecode()
537 */
538 memset(bytes_out, 0, 8);
539 numbytes = msHexDecode(string_buf, bytes_out, -1);
540 printf("msHexDecode(%s, -1) = %d, bytes_out = %x, %x, %x, %x, %x, %x, %x, %x\n",
541 string_buf, numbytes,
542 bytes_out[0], bytes_out[1], bytes_out[2], bytes_out[3],
543 bytes_out[4], bytes_out[5], bytes_out[6], bytes_out[7]);
544
545 memset(bytes_out, 0, 8);
546 numbytes = msHexDecode(string_buf, bytes_out, 4);
547 printf("msHexDecode(%s, 4) = %d, bytes_out = %x, %x, %x, %x, %x, %x, %x, %x\n",
548 string_buf, numbytes,
549 bytes_out[0], bytes_out[1], bytes_out[2], bytes_out[3],
550 bytes_out[4], bytes_out[5], bytes_out[6], bytes_out[7]);
551
552 memset(bytes_out, 0, 8);
553 numbytes = msHexDecode(string_buf, bytes_out, 20);
554 printf("msHexDecode(%s, 20) = %d, bytes_out = %x, %x, %x, %x, %x, %x, %x, %x\n",
555 string_buf, numbytes,
556 bytes_out[0], bytes_out[1], bytes_out[2], bytes_out[3],
557 bytes_out[4], bytes_out[5], bytes_out[6], bytes_out[7]);
558
559 /*
560 ** Test loading encryption key
561 */
562 if (msReadEncryptionKeyFromFile("/tmp/test.key", encryption_key) != MS_SUCCESS)
563 {
564 printf("msReadEncryptionKeyFromFile() = MS_FAILURE\n");
565 printf("Aborting tests!\n");
566 msWriteError(stderr);
567 return -1;
568 }
569 else
570 {
571 msHexEncode(encryption_key, string_buf, MS_ENCRYPTION_KEY_SIZE);
572 printf("msReadEncryptionKeyFromFile() returned '%s'\n", string_buf);
573 }
574
575 /*
576 ** Test Encryption/Decryption
577 */
578
579 /* First with an 8 bytes input string (test boundaries) */

Callers

nothing calls this directly

Calls 9

msHexEncodeFunction · 0.85
msHexDecodeFunction · 0.85
msWriteErrorFunction · 0.85
msEncryptStringWithKeyFunction · 0.85
msDecryptStringWithKeyFunction · 0.85
msDecryptStringTokensFunction · 0.85
msFreeFunction · 0.85
msFreeMapFunction · 0.85

Tested by

no test coverage detected