VirtualBox

Changeset 64817 in vbox


Ignore:
Timestamp:
Dec 8, 2016 9:44:02 PM (8 years ago)
Author:
vboxsync
Message:

IPRT: Added RTAsn1QueryObjIdName and RTCrDigestTypeToName.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/asn1.h

    r62473 r64817  
    20842084RTDECL(int) RTAsn1Dump(PCRTASN1CORE pAsn1Core, uint32_t fFlags, uint32_t uLevel, PFNRTDUMPPRINTFV pfnPrintfV, void *pvUser);
    20852085
     2086/**
     2087 * Queries the name for an object identifier.
     2088 *
     2089 * This API is very simple due to how we store the data.
     2090 *
     2091 * @returns IPRT status code.
     2092 * @retval  VINF_SUCCESS on success.
     2093 * @retval  VERR_NOT_FOUND if not found.
     2094 * @retval  VERR_BUFFER_OVERFLOW if more buffer space is required.
     2095 *
     2096 * @param   pauComponents   The components making up the object ID.
     2097 * @param   cComponents     The number of components.
     2098 * @param   pszDst          Where to store the name if found.
     2099 * @param   cbDst           The size of the destination buffer.
     2100 */
     2101RTDECL(int) RTAsn1QueryObjIdName(PCRTASN1OBJID pObjId, char *pszDst, size_t cbDst);
     2102
    20862103/** @} */
    20872104
  • trunk/include/iprt/crypto/digest.h

    r62474 r64817  
    205205RTDECL(const char *) RTCrDigestTypeToAlgorithmOid(RTDIGESTTYPE enmDigestType);
    206206
     207/**
     208 * Translates an IPRT digest type value to a name/descriptive string.
     209 *
     210 * The purpose here is for human readable output rather than machine readable
     211 * output, i.e. the names aren't set in stone.
     212 *
     213 * @returns Pointer to read-only string, NULL if unknown type.
     214 * @param       enmDigestType       The IPRT digest type value to convert.
     215 */
     216RTDECL(const char *) RTCrDigestTypeToName(RTDIGESTTYPE enmDigestType);
     217
    207218/** @} */
    208219
  • trunk/include/iprt/mangling.h

    r64602 r64817  
    24422442# define RTAsn1CursorSetInfoV                           RT_MANGLER(RTAsn1CursorSetInfoV)
    24432443# define RTAsn1Dump                                     RT_MANGLER(RTAsn1Dump)
     2444# define RTAsn1QueryObjIdName                           RT_MANGLER(RTAsn1QueryObjIdName)
    24442445# define RTAsn1EncodePrepare                            RT_MANGLER(RTAsn1EncodePrepare)
    24452446# define RTAsn1EncodeRecalcHdrSize                      RT_MANGLER(RTAsn1EncodeRecalcHdrSize)
     
    27762777# define RTCrDigestFindByType                           RT_MANGLER(RTCrDigestFindByType)
    27772778# define RTCrDigestTypeToAlgorithmOid                   RT_MANGLER(RTCrDigestTypeToAlgorithmOid)
     2779# define RTCrDigestTypeToName                           RT_MANGLER(RTCrDigestTypeToName)
    27782780# define RTCrRsaDigestInfo_DecodeAsn1                   RT_MANGLER(RTCrRsaDigestInfo_DecodeAsn1)
    27792781# define RTCrRsaOtherPrimeInfo_DecodeAsn1               RT_MANGLER(RTCrRsaOtherPrimeInfo_DecodeAsn1)
  • trunk/src/VBox/Runtime/common/asn1/asn1-dump.cpp

    r62477 r64817  
    142142            }
    143143            else
    144                 return &g_aSmallOidTable[iEntry];
     144                return &g_aSmallOidTable[i];
    145145        }
    146146    }
     
    149149
    150150
    151 
    152151/**
    153152 * Queries the name for an object identifier.
    154153 *
    155  * @returns true if found, false if not.
     154 * @returns IPRT status code (VINF_SUCCESS, VERR_NOT_FOUND,
     155 *          VERR_BUFFER_OVERFLOW)
    156156 * @param   pauComponents   The components making up the object ID.
    157157 * @param   cComponents     The number of components.
     
    159159 * @param   cbDst           The size of the destination buffer.
    160160 */
    161 static bool rtOidDbQueryObjIdName(uint32_t const *pauComponents, uint8_t cComponents, char *pszDst, size_t cbDst)
    162 {
     161static int rtOidDbQueryObjIdName(uint32_t const *pauComponents, uint8_t cComponents, char *pszDst, size_t cbDst)
     162{
     163    int rc = VERR_NOT_FOUND;
    163164    if (cComponents > 0)
    164165    {
     
    181182                        if (RTBldProgStrTabQueryString(&g_OidDbStrTab, pSmallHit->offString,
    182183                                                       pSmallHit->cchString, pszDst, cbDst) >= 0)
    183                             return true;
     184                            return VINF_SUCCESS;
     185                        rc = VERR_BUFFER_OVERFLOW;
    184186                        break;
    185187                    }
     
    202204                        if (RTBldProgStrTabQueryString(&g_OidDbStrTab, pBigHit->offString,
    203205                                                       pBigHit->cchString, pszDst, cbDst) >= 0)
    204                             return true;
     206                            return VINF_SUCCESS;
     207                        rc = VERR_BUFFER_OVERFLOW;
    205208                        break;
    206209                    }
     
    218221    }
    219222
    220     return false;
     223    return rc;
     224}
     225
     226
     227/**
     228 * Queries the name for an object identifier.
     229 *
     230 * This API is simple and more or less requires a
     231 *
     232 * @returns IPRT status code.
     233 * @retval  VINF_SUCCESS on success.
     234 * @retval  VERR_NOT_FOUND if not found.
     235 * @retval  VERR_BUFFER_OVERFLOW if more buffer space is required.
     236 *
     237 * @param   pauComponents   The components making up the object ID.
     238 * @param   cComponents     The number of components.
     239 * @param   pszDst          Where to store the name if found.
     240 * @param   cbDst           The size of the destination buffer.
     241 */
     242RTDECL(int) RTAsn1QueryObjIdName(PCRTASN1OBJID pObjId, char *pszDst, size_t cbDst)
     243{
     244    return rtOidDbQueryObjIdName(pObjId->pauComponents, pObjId->cComponents, pszDst, cbDst);
    221245}
    222246
     
    422446                PCRTASN1OBJID pObjId = (PCRTASN1OBJID)pAsn1Core;
    423447                char szName[64];
    424                 if (rtOidDbQueryObjIdName(pObjId->pauComponents, pObjId->cComponents, szName, sizeof(szName)))
     448                if (rtOidDbQueryObjIdName(pObjId->pauComponents, pObjId->cComponents, szName, sizeof(szName)) == VINF_SUCCESS)
    425449                    rtAsn1DumpPrintf(pData, "OBJECT IDENTIFIER %s%s ('%s')\n",
    426450                                     pszDefault, szName, ((PCRTASN1OBJID)pAsn1Core)->szObjId);
  • trunk/src/VBox/Runtime/common/crypto/digest-core.cpp

    r62477 r64817  
    398398}
    399399
     400
     401RTDECL(const char *) RTCrDigestTypeToName(RTDIGESTTYPE enmDigestType)
     402{
     403    switch (enmDigestType)
     404    {
     405        case RTDIGESTTYPE_CRC32:        return "CRC32";
     406        case RTDIGESTTYPE_CRC64:        return "CRC64";
     407        case RTDIGESTTYPE_MD2:          return "MD2";
     408        case RTDIGESTTYPE_MD4:          return "MD4";
     409        case RTDIGESTTYPE_MD5:          return "MD5";
     410        case RTDIGESTTYPE_SHA1:         return "SHA-1";
     411        case RTDIGESTTYPE_SHA224:       return "SHA-224";
     412        case RTDIGESTTYPE_SHA256:       return "SHA-256";
     413        case RTDIGESTTYPE_SHA384:       return "SHA-384";
     414        case RTDIGESTTYPE_SHA512:       return "SHA-512";
     415        case RTDIGESTTYPE_SHA512T224:   return "SHA-512/224";
     416        case RTDIGESTTYPE_SHA512T256:   return "SHA-512/256";
     417        default:                        return NULL;
     418    }
     419}
     420
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