VirtualBox

Changeset 85614 in vbox for trunk/include


Ignore:
Timestamp:
Aug 5, 2020 1:27:58 PM (4 years ago)
Author:
vboxsync
Message:

IPRT: Adding SHA-3. bugref:9734

Location:
trunk/include/iprt
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/crypto/x509.h

    r84379 r85614  
    152152#define RTCRX509ALGORITHMIDENTIFIERID_SHA512T224        "2.16.840.1.101.3.4.2.5"
    153153#define RTCRX509ALGORITHMIDENTIFIERID_SHA512T256        "2.16.840.1.101.3.4.2.6"
     154#define RTCRX509ALGORITHMIDENTIFIERID_SHA3_224          "2.16.840.1.101.3.4.2.7"
     155#define RTCRX509ALGORITHMIDENTIFIERID_SHA3_256          "2.16.840.1.101.3.4.2.8"
     156#define RTCRX509ALGORITHMIDENTIFIERID_SHA3_384          "2.16.840.1.101.3.4.2.9"
     157#define RTCRX509ALGORITHMIDENTIFIERID_SHA3_512          "2.16.840.1.101.3.4.2.10"
    154158#define RTCRX509ALGORITHMIDENTIFIERID_WHIRLPOOL         "1.0.10118.3.0.55"
    155159/** @} */
     
    170174#define RTCRX509ALGORITHMIDENTIFIERID_SHA512T224_WITH_RSA   "1.2.840.113549.1.1.15"
    171175#define RTCRX509ALGORITHMIDENTIFIERID_SHA512T256_WITH_RSA   "1.2.840.113549.1.1.16"
     176#define RTCRX509ALGORITHMIDENTIFIERID_SHA3_224_WITH_RSA     "2.16.840.1.101.3.4.3.13"
     177#define RTCRX509ALGORITHMIDENTIFIERID_SHA3_256_WITH_RSA     "2.16.840.1.101.3.4.3.14"
     178#define RTCRX509ALGORITHMIDENTIFIERID_SHA3_384_WITH_RSA     "2.16.840.1.101.3.4.3.15"
     179#define RTCRX509ALGORITHMIDENTIFIERID_SHA3_512_WITH_RSA     "2.16.840.1.101.3.4.3.16"
    172180/** @} */
    173181
  • trunk/include/iprt/mangling.h

    r85311 r85614  
    20482048# define RTSha512t256Init                               RT_MANGLER(RTSha512t256Init)
    20492049# define RTSha512t256ToString                           RT_MANGLER(RTSha512t256ToString)
    2050 # define RTSha512t256Update                             RT_MANGLER(RTSha512t256Update)
     2050# define RTSha3t224                                     RT_MANGLER(RTSha3t224)
     2051# define RTSha3t224Check                                RT_MANGLER(RTSha3t224Check
     2052# define RTSha3t224Cleanup                              RT_MANGLER(RTSha3t224Cleanup
     2053# define RTSha3t224Clone                                RT_MANGLER(RTSha3t224Clone
     2054# define RTSha3t224Init                                 RT_MANGLER(RTSha3t224Init
     2055# define RTSha3t224Final                                RT_MANGLER(RTSha3t224Final
     2056# define RTSha3t224FromString                           RT_MANGLER(RTSha3t224FromString
     2057# define RTSha3t224ToString                             RT_MANGLER(RTSha3t224ToString
     2058# define RTSha3t224Update                               RT_MANGLER(RTSha3t224Update
     2059# define RTSha3t256                                     RT_MANGLER(RTSha3t256)
     2060# define RTSha3t256Check                                RT_MANGLER(RTSha3t256Check
     2061# define RTSha3t256Cleanup                              RT_MANGLER(RTSha3t256Cleanup
     2062# define RTSha3t256Clone                                RT_MANGLER(RTSha3t256Clone
     2063# define RTSha3t256Init                                 RT_MANGLER(RTSha3t256Init
     2064# define RTSha3t256Final                                RT_MANGLER(RTSha3t256Final
     2065# define RTSha3t256FromString                           RT_MANGLER(RTSha3t256FromString
     2066# define RTSha3t256ToString                             RT_MANGLER(RTSha3t256ToString
     2067# define RTSha3t256Update                               RT_MANGLER(RTSha3t256Update
     2068# define RTSha3t384                                     RT_MANGLER(RTSha3t384)
     2069# define RTSha3t384Check                                RT_MANGLER(RTSha3t384Check
     2070# define RTSha3t384Cleanup                              RT_MANGLER(RTSha3t384Cleanup
     2071# define RTSha3t384Clone                                RT_MANGLER(RTSha3t384Clone
     2072# define RTSha3t384Init                                 RT_MANGLER(RTSha3t384Init
     2073# define RTSha3t384Final                                RT_MANGLER(RTSha3t384Final
     2074# define RTSha3t384FromString                           RT_MANGLER(RTSha3t384FromString
     2075# define RTSha3t384ToString                             RT_MANGLER(RTSha3t384ToString
     2076# define RTSha3t384Update                               RT_MANGLER(RTSha3t384Update
     2077# define RTSha3t512                                     RT_MANGLER(RTSha3t512)
     2078# define RTSha3t512Check                                RT_MANGLER(RTSha3t512Check
     2079# define RTSha3t512Cleanup                              RT_MANGLER(RTSha3t512Cleanup
     2080# define RTSha3t512Clone                                RT_MANGLER(RTSha3t512Clone
     2081# define RTSha3t512Init                                 RT_MANGLER(RTSha3t512Init
     2082# define RTSha3t512Final                                RT_MANGLER(RTSha3t512Final
     2083# define RTSha3t512FromString                           RT_MANGLER(RTSha3t512FromString
     2084# define RTSha3t512ToString                             RT_MANGLER(RTSha3t512ToString
     2085# define RTSha3t512Update                               RT_MANGLER(RTSha3t512Update
    20512086# define RTShMemClose                                   RT_MANGLER(RTShMemClose)
    20522087# define RTShMemDelete                                  RT_MANGLER(RTShMemDelete)
  • trunk/include/iprt/sha.h

    r82968 r85614  
    514514
    515515
     516/**
     517 * SHA3 context.
     518 */
     519typedef union RTSHA3CONTEXT
     520{
     521    uint64_t                a64Padding[26];
     522    uint8_t                 abPadding[208];
     523#ifdef RT_SHA3_PRIVATE_CONTEXT
     524    RTSHA3PRIVATECTX        Private;
     525#endif
     526#ifdef RT_SHA3_PRIVATE_ALT_CONTEXT
     527    RTSHA3ALTPRIVATECTX     AltPrivate;
     528#endif
     529} RTSHA3CONTEXT;
     530/** Pointer to an SHA3 context. */
     531typedef RTSHA3CONTEXT *PRTSHA3CONTEXT;
     532
     533/** Macro for declaring the interface for a SHA3 variation.
     534 *
     535 * @note The interface differes slightly from the older checksums:
     536 *          - Must call Final and/or Cleanup method.
     537 *          - Must use Clone instead of memcpy'ing the context.
     538 *          - Status codes are returned, Init may really fail.
     539 *
     540 * @internal */
     541#define RTSHA3_DECLARE_VARIANT(a_Bits) \
     542    typedef struct RT_CONCAT3(RTSHA3T,a_Bits,CONTEXT) { RTSHA3CONTEXT Sha3; } RT_CONCAT3(RTSHA3T,a_Bits,CONTEXT); \
     543    typedef RT_CONCAT3(RTSHA3T,a_Bits,CONTEXT) *RT_CONCAT3(PRTSHA3T,a_Bits,CONTEXT); \
     544    RTDECL(int)  RT_CONCAT(RTSha3t,a_Bits)(const void *pvBuf, size_t cbBuf, uint8_t pabHash[RT_CONCAT3(RTSHA3_,a_Bits,_HASH_SIZE)]); \
     545    RTDECL(bool) RT_CONCAT3(RTSha3t,a_Bits,Check)(const void *pvBuf, size_t cbBuf, uint8_t const pabHash[RT_CONCAT3(RTSHA3_,a_Bits,_HASH_SIZE)]); \
     546    RTDECL(int)  RT_CONCAT3(RTSha3t,a_Bits,Init)(RT_CONCAT3(PRTSHA3T,a_Bits,CONTEXT) pCtx); \
     547    RTDECL(int)  RT_CONCAT3(RTSha3t,a_Bits,Update)(RT_CONCAT3(PRTSHA3T,a_Bits,CONTEXT) pCtx, const void *pvBuf, size_t cbBuf); \
     548    RTDECL(int)  RT_CONCAT3(RTSha3t,a_Bits,Final)(RT_CONCAT3(PRTSHA3T,a_Bits,CONTEXT) pCtx, uint8_t pabHash[RT_CONCAT3(RTSHA3_,a_Bits,_HASH_SIZE)]); \
     549    RTDECL(int)  RT_CONCAT3(RTSha3t,a_Bits,Cleanup)(RT_CONCAT3(PRTSHA3T,a_Bits,CONTEXT) pCtx); \
     550    RTDECL(int)  RT_CONCAT3(RTSha3t,a_Bits,Clone)(RT_CONCAT3(PRTSHA3T,a_Bits,CONTEXT) pCtx, RT_CONCAT3(RTSHA3T,a_Bits,CONTEXT) const *pCtxSrc); \
     551    RTDECL(int)  RT_CONCAT3(RTSha3t,a_Bits,ToString)(uint8_t const pabHash[RT_CONCAT3(RTSHA3_,a_Bits,_HASH_SIZE)], char *pszDigest, size_t cchDigest); \
     552    RTDECL(int)  RT_CONCAT3(RTSha3t,a_Bits,FromString)(char const *pszDigest, uint8_t pabHash[RT_CONCAT3(RTSHA3_,a_Bits,_HASH_SIZE)])
     553
     554/** The size of a SHA-224 hash. */
     555#define RTSHA3_224_HASH_SIZE     28
     556/** The length of a SHA-224 digest string. The terminator is not included. */
     557#define RTSHA3_224_DIGEST_LEN    56
     558RTSHA3_DECLARE_VARIANT(224);
     559
     560/** The size of a SHA-256 hash. */
     561#define RTSHA3_256_HASH_SIZE     32
     562/** The length of a SHA-256 digest string. The terminator is not included. */
     563#define RTSHA3_256_DIGEST_LEN    64
     564RTSHA3_DECLARE_VARIANT(256);
     565
     566/** The size of a SHA-384 hash. */
     567#define RTSHA3_384_HASH_SIZE     48
     568/** The length of a SHA-384 digest string. The terminator is not included. */
     569#define RTSHA3_384_DIGEST_LEN    96
     570RTSHA3_DECLARE_VARIANT(384);
     571
     572/** The size of a SHA-512 hash. */
     573#define RTSHA3_512_HASH_SIZE     64
     574/** The length of a SHA-512 digest string. The terminator is not included. */
     575#define RTSHA3_512_DIGEST_LEN    128
     576RTSHA3_DECLARE_VARIANT(512);
     577
    516578/** @} */
    517579
  • trunk/include/iprt/types.h

    r85121 r85614  
    29822982    /** SHA-512/256 checksum. */
    29832983    RTDIGESTTYPE_SHA512T256,
     2984    /** SHA3-224 checksum. */
     2985    RTDIGESTTYPE_SHA3_224,
     2986    /** SHA3-256 checksum. */
     2987    RTDIGESTTYPE_SHA3_256,
     2988    /** SHA3-384 checksum. */
     2989    RTDIGESTTYPE_SHA3_384,
     2990    /** SHA3-512 checksum. */
     2991    RTDIGESTTYPE_SHA3_512,
     2992#if 0
     2993    /** SHAKE128 checksum. */
     2994    RTDIGESTTYPE_SHAKE128,
     2995    /** SHAKE256 checksum. */
     2996    RTDIGESTTYPE_SHAKE256,
     2997#endif
    29842998    /** End of valid types. */
    29852999    RTDIGESTTYPE_END,
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette