Changeset 85614 in vbox for trunk/src/VBox/Runtime/common/crypto
- Timestamp:
- Aug 5, 2020 1:27:58 PM (4 years ago)
- Location:
- trunk/src/VBox/Runtime/common/crypto
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/crypto/digest-builtin.cpp
r85121 r85614 602 602 }; 603 603 #endif /* !IPRT_WITHOUT_SHA512T256 */ 604 605 #ifndef IPRT_WITHOUT_SHA3 606 607 /* 608 * SHA3-224 609 */ 610 611 /** @impl_interface_method{RTCRDIGESTDESC::pfnUpdate} */ 612 static DECLCALLBACK(void) rtCrDigestSha3t224_Update(void *pvState, const void *pvData, size_t cbData) 613 { 614 int rc = RTSha3t224Update((PRTSHA3T224CONTEXT)pvState, pvData, cbData); 615 AssertRC(rc); 616 } 617 618 /** @impl_interface_method{RTCRDIGESTDESC::pfnFinal} */ 619 static DECLCALLBACK(void) rtCrDigestSha3t224_Final(void *pvState, uint8_t *pbHash) 620 { 621 int rc = RTSha3t224Final((PRTSHA3T224CONTEXT)pvState, pbHash); 622 AssertRC(rc); 623 } 624 625 /** @impl_interface_method{RTCRDIGESTDESC::pfnInit} */ 626 static DECLCALLBACK(int) rtCrDigestSha3t224_Init(void *pvState, void *pvOpaque, bool fReInit) 627 { 628 RT_NOREF_PV(pvOpaque); 629 AssertReturn(pvOpaque == NULL, VERR_INVALID_PARAMETER); 630 if (fReInit) 631 RTSha3t224Cleanup((PRTSHA3T224CONTEXT)pvState); 632 return RTSha3t224Init((PRTSHA3T224CONTEXT)pvState); 633 } 634 635 /** @impl_interface_method{RTCRDIGESTDESC::pfnDelete} */ 636 static DECLCALLBACK(void) rtCrDigestSha3t224_Delete(void *pvState) 637 { 638 RTSha3t224Cleanup((PRTSHA3T224CONTEXT)pvState); 639 } 640 641 /** @impl_interface_method{RTCRDIGESTDESC::pfnDelete} */ 642 static DECLCALLBACK(int) rtCrDigestSha3t224_Clone(void *pvState, void const *pvSrcState) 643 { 644 return RTSha3t224Clone((PRTSHA3T224CONTEXT)pvState, (PRTSHA3T224CONTEXT)pvSrcState); 645 } 646 647 /** SHA3-224 alias ODIs. */ 648 static const char * const g_apszSha3t224Aliases[] = 649 { 650 "2.16.840.1.101.3.4.3.13", 651 NULL 652 }; 653 654 /** SHA3-224 descriptor. */ 655 static RTCRDIGESTDESC const g_rtCrDigestSha3t224Desc = 656 { 657 "sha3-224", 658 "2.16.840.1.101.3.4.2.7", 659 g_apszSha3t224Aliases, 660 RTDIGESTTYPE_SHA3_224, 661 RTSHA3_224_HASH_SIZE, 662 sizeof(RTSHA3T224CONTEXT), 663 0, 664 NULL, 665 NULL, 666 rtCrDigestSha3t224_Update, 667 rtCrDigestSha3t224_Final, 668 rtCrDigestSha3t224_Init, 669 rtCrDigestSha3t224_Delete, 670 rtCrDigestSha3t224_Clone, 671 NULL, 672 NULL, 673 }; 674 675 676 /* 677 * SHA3-256 678 */ 679 680 /** @impl_interface_method{RTCRDIGESTDESC::pfnUpdate} */ 681 static DECLCALLBACK(void) rtCrDigestSha3t256_Update(void *pvState, const void *pvData, size_t cbData) 682 { 683 int rc = RTSha3t256Update((PRTSHA3T256CONTEXT)pvState, pvData, cbData); 684 AssertRC(rc); 685 } 686 687 /** @impl_interface_method{RTCRDIGESTDESC::pfnFinal} */ 688 static DECLCALLBACK(void) rtCrDigestSha3t256_Final(void *pvState, uint8_t *pbHash) 689 { 690 int rc = RTSha3t256Final((PRTSHA3T256CONTEXT)pvState, pbHash); 691 AssertRC(rc); 692 } 693 694 /** @impl_interface_method{RTCRDIGESTDESC::pfnInit} */ 695 static DECLCALLBACK(int) rtCrDigestSha3t256_Init(void *pvState, void *pvOpaque, bool fReInit) 696 { 697 RT_NOREF_PV(pvOpaque); 698 AssertReturn(pvOpaque == NULL, VERR_INVALID_PARAMETER); 699 if (fReInit) 700 RTSha3t256Cleanup((PRTSHA3T256CONTEXT)pvState); 701 return RTSha3t256Init((PRTSHA3T256CONTEXT)pvState); 702 } 703 704 /** @impl_interface_method{RTCRDIGESTDESC::pfnDelete} */ 705 static DECLCALLBACK(void) rtCrDigestSha3t256_Delete(void *pvState) 706 { 707 RTSha3t256Cleanup((PRTSHA3T256CONTEXT)pvState); 708 } 709 710 /** @impl_interface_method{RTCRDIGESTDESC::pfnDelete} */ 711 static DECLCALLBACK(int) rtCrDigestSha3t256_Clone(void *pvState, void const *pvSrcState) 712 { 713 return RTSha3t256Clone((PRTSHA3T256CONTEXT)pvState, (PRTSHA3T256CONTEXT)pvSrcState); 714 } 715 716 /** SHA3-256 alias ODIs. */ 717 static const char * const g_apszSha3t256Aliases[] = 718 { 719 "2.16.840.1.101.3.4.3.14", 720 NULL 721 }; 722 723 /** SHA3-256 descriptor. */ 724 static RTCRDIGESTDESC const g_rtCrDigestSha3t256Desc = 725 { 726 "sha3-256", 727 "2.16.840.1.101.3.4.2.8", 728 g_apszSha3t256Aliases, 729 RTDIGESTTYPE_SHA3_256, 730 RTSHA3_256_HASH_SIZE, 731 sizeof(RTSHA3T256CONTEXT), 732 0, 733 NULL, 734 NULL, 735 rtCrDigestSha3t256_Update, 736 rtCrDigestSha3t256_Final, 737 rtCrDigestSha3t256_Init, 738 rtCrDigestSha3t256_Delete, 739 rtCrDigestSha3t256_Clone, 740 NULL, 741 NULL, 742 }; 743 744 745 /* 746 * SHA3-384 747 */ 748 749 /** @impl_interface_method{RTCRDIGESTDESC::pfnUpdate} */ 750 static DECLCALLBACK(void) rtCrDigestSha3t384_Update(void *pvState, const void *pvData, size_t cbData) 751 { 752 int rc = RTSha3t384Update((PRTSHA3T384CONTEXT)pvState, pvData, cbData); 753 AssertRC(rc); 754 } 755 756 /** @impl_interface_method{RTCRDIGESTDESC::pfnFinal} */ 757 static DECLCALLBACK(void) rtCrDigestSha3t384_Final(void *pvState, uint8_t *pbHash) 758 { 759 int rc = RTSha3t384Final((PRTSHA3T384CONTEXT)pvState, pbHash); 760 AssertRC(rc); 761 } 762 763 /** @impl_interface_method{RTCRDIGESTDESC::pfnInit} */ 764 static DECLCALLBACK(int) rtCrDigestSha3t384_Init(void *pvState, void *pvOpaque, bool fReInit) 765 { 766 RT_NOREF_PV(pvOpaque); 767 AssertReturn(pvOpaque == NULL, VERR_INVALID_PARAMETER); 768 if (fReInit) 769 RTSha3t384Cleanup((PRTSHA3T384CONTEXT)pvState); 770 return RTSha3t384Init((PRTSHA3T384CONTEXT)pvState); 771 } 772 773 /** @impl_interface_method{RTCRDIGESTDESC::pfnDelete} */ 774 static DECLCALLBACK(void) rtCrDigestSha3t384_Delete(void *pvState) 775 { 776 RTSha3t384Cleanup((PRTSHA3T384CONTEXT)pvState); 777 } 778 779 /** @impl_interface_method{RTCRDIGESTDESC::pfnDelete} */ 780 static DECLCALLBACK(int) rtCrDigestSha3t384_Clone(void *pvState, void const *pvSrcState) 781 { 782 return RTSha3t384Clone((PRTSHA3T384CONTEXT)pvState, (PRTSHA3T384CONTEXT)pvSrcState); 783 } 784 785 /** SHA3-384 alias ODIs. */ 786 static const char * const g_apszSha3t384Aliases[] = 787 { 788 "2.16.840.1.101.3.4.3.15", 789 NULL 790 }; 791 792 /** SHA3-384 descriptor. */ 793 static RTCRDIGESTDESC const g_rtCrDigestSha3t384Desc = 794 { 795 "sha3-384", 796 "2.16.840.1.101.3.4.2.9", 797 g_apszSha3t384Aliases, 798 RTDIGESTTYPE_SHA3_384, 799 RTSHA3_384_HASH_SIZE, 800 sizeof(RTSHA3T384CONTEXT), 801 0, 802 NULL, 803 NULL, 804 rtCrDigestSha3t384_Update, 805 rtCrDigestSha3t384_Final, 806 rtCrDigestSha3t384_Init, 807 rtCrDigestSha3t384_Delete, 808 rtCrDigestSha3t384_Clone, 809 NULL, 810 NULL, 811 }; 812 813 814 /* 815 * SHA3-512 816 */ 817 818 /** @impl_interface_method{RTCRDIGESTDESC::pfnUpdate} */ 819 static DECLCALLBACK(void) rtCrDigestSha3t512_Update(void *pvState, const void *pvData, size_t cbData) 820 { 821 int rc = RTSha3t512Update((PRTSHA3T512CONTEXT)pvState, pvData, cbData); 822 AssertRC(rc); 823 } 824 825 /** @impl_interface_method{RTCRDIGESTDESC::pfnFinal} */ 826 static DECLCALLBACK(void) rtCrDigestSha3t512_Final(void *pvState, uint8_t *pbHash) 827 { 828 int rc = RTSha3t512Final((PRTSHA3T512CONTEXT)pvState, pbHash); 829 AssertRC(rc); 830 } 831 832 /** @impl_interface_method{RTCRDIGESTDESC::pfnInit} */ 833 static DECLCALLBACK(int) rtCrDigestSha3t512_Init(void *pvState, void *pvOpaque, bool fReInit) 834 { 835 RT_NOREF_PV(pvOpaque); 836 AssertReturn(pvOpaque == NULL, VERR_INVALID_PARAMETER); 837 if (fReInit) 838 RTSha3t512Cleanup((PRTSHA3T512CONTEXT)pvState); 839 return RTSha3t512Init((PRTSHA3T512CONTEXT)pvState); 840 } 841 842 /** @impl_interface_method{RTCRDIGESTDESC::pfnDelete} */ 843 static DECLCALLBACK(void) rtCrDigestSha3t512_Delete(void *pvState) 844 { 845 RTSha3t512Cleanup((PRTSHA3T512CONTEXT)pvState); 846 } 847 848 /** @impl_interface_method{RTCRDIGESTDESC::pfnDelete} */ 849 static DECLCALLBACK(int) rtCrDigestSha3t512_Clone(void *pvState, void const *pvSrcState) 850 { 851 return RTSha3t512Clone((PRTSHA3T512CONTEXT)pvState, (PRTSHA3T512CONTEXT)pvSrcState); 852 } 853 854 /** SHA3-512 alias ODIs. */ 855 static const char * const g_apszSha3t512Aliases[] = 856 { 857 "2.16.840.1.101.3.4.3.16", 858 NULL 859 }; 860 861 /** SHA3-512 descriptor. */ 862 static RTCRDIGESTDESC const g_rtCrDigestSha3t512Desc = 863 { 864 "sha3-512", 865 "2.16.840.1.101.3.4.2.10", 866 g_apszSha3t512Aliases, 867 RTDIGESTTYPE_SHA3_512, 868 RTSHA3_512_HASH_SIZE, 869 sizeof(RTSHA3T512CONTEXT), 870 0, 871 NULL, 872 NULL, 873 rtCrDigestSha3t512_Update, 874 rtCrDigestSha3t512_Final, 875 rtCrDigestSha3t512_Init, 876 rtCrDigestSha3t512_Delete, 877 rtCrDigestSha3t512_Clone, 878 NULL, 879 NULL, 880 }; 881 882 #endif /* !IPRT_WITHOUT_SHA3 */ 604 883 605 884 … … 628 907 #ifndef IPRT_WITHOUT_SHA512T256 629 908 &g_rtCrDigestSha512t256Desc, 909 #endif 910 #ifndef IPRT_WITHOUT_SHA3 911 &g_rtCrDigestSha3t224Desc, 912 &g_rtCrDigestSha3t256Desc, 913 &g_rtCrDigestSha3t384Desc, 914 &g_rtCrDigestSha3t512Desc, 630 915 #endif 631 916 }; -
trunk/src/VBox/Runtime/common/crypto/digest-core.cpp
r84248 r85614 428 428 case RTDIGESTTYPE_SHA512T224: return RTCRX509ALGORITHMIDENTIFIERID_SHA512T224; 429 429 case RTDIGESTTYPE_SHA512T256: return RTCRX509ALGORITHMIDENTIFIERID_SHA512T256; 430 case RTDIGESTTYPE_SHA3_224: return RTCRX509ALGORITHMIDENTIFIERID_SHA3_224; 431 case RTDIGESTTYPE_SHA3_256: return RTCRX509ALGORITHMIDENTIFIERID_SHA3_256; 432 case RTDIGESTTYPE_SHA3_384: return RTCRX509ALGORITHMIDENTIFIERID_SHA3_384; 433 case RTDIGESTTYPE_SHA3_512: return RTCRX509ALGORITHMIDENTIFIERID_SHA3_512; 430 434 default: return NULL; 431 435 } … … 449 453 case RTDIGESTTYPE_SHA512T224: return "SHA-512/224"; 450 454 case RTDIGESTTYPE_SHA512T256: return "SHA-512/256"; 455 case RTDIGESTTYPE_SHA3_224: return "SHA3-224"; 456 case RTDIGESTTYPE_SHA3_256: return "SHA3-256"; 457 case RTDIGESTTYPE_SHA3_384: return "SHA3-384"; 458 case RTDIGESTTYPE_SHA3_512: return "SHA3-512"; 451 459 default: return NULL; 452 460 } … … 470 478 case RTDIGESTTYPE_SHA512T224: return 224 / 8; 471 479 case RTDIGESTTYPE_SHA512T256: return 256 / 8; 480 case RTDIGESTTYPE_SHA3_224: return 224 / 8; 481 case RTDIGESTTYPE_SHA3_256: return 256 / 8; 482 case RTDIGESTTYPE_SHA3_384: return 384 / 8; 483 case RTDIGESTTYPE_SHA3_512: return 512 / 8; 472 484 default: 473 485 AssertFailed();
Note:
See TracChangeset
for help on using the changeset viewer.