Changeset 59689 in vbox for trunk/src/VBox/Runtime/common/crypto/x509-core.cpp
- Timestamp:
- Feb 15, 2016 9:25:36 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/crypto/x509-core.cpp
r57574 r59689 127 127 128 128 129 RTDECL(int) RTCrX509AlgorithmIdentifier_CompareDigest AndEncryptedDigest(PCRTCRX509ALGORITHMIDENTIFIER pDigest,130 PCRTCRX509ALGORITHMIDENTIFIER pEncryptedDigest)129 RTDECL(int) RTCrX509AlgorithmIdentifier_CompareDigestOidAndEncryptedDigestOid(const char *pszDigestOid, 130 const char *pszEncryptedDigestOid) 131 131 { 132 132 /* common */ 133 if (!strcmp(p Digest->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_MD5))134 { 135 if (!strcmp(p EncryptedDigest->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_MD5_WITH_RSA))133 if (!strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_MD5)) 134 { 135 if (!strcmp(pszEncryptedDigestOid, RTCRX509ALGORITHMIDENTIFIERID_MD5_WITH_RSA)) 136 136 return 0; 137 137 } 138 else if (!strcmp(p Digest->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA1))139 { 140 if (!strcmp(p EncryptedDigest->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA1_WITH_RSA))138 else if (!strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA1)) 139 { 140 if (!strcmp(pszEncryptedDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA1_WITH_RSA)) 141 141 return 0; 142 142 } 143 else if (!strcmp(p Digest->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA256))144 { 145 if (!strcmp(p EncryptedDigest->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA256_WITH_RSA))143 else if (!strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA256)) 144 { 145 if (!strcmp(pszEncryptedDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA256_WITH_RSA)) 146 146 return 0; 147 147 } 148 else if (!strcmp(p Digest->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA512))149 { 150 if (!strcmp(p EncryptedDigest->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA512_WITH_RSA))148 else if (!strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA512)) 149 { 150 if (!strcmp(pszEncryptedDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA512_WITH_RSA)) 151 151 return 0; 152 152 } 153 153 /* Less common. */ 154 else if (!strcmp(p Digest->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_MD2))155 { 156 if (!strcmp(p EncryptedDigest->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_MD2_WITH_RSA))154 else if (!strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_MD2)) 155 { 156 if (!strcmp(pszEncryptedDigestOid, RTCRX509ALGORITHMIDENTIFIERID_MD2_WITH_RSA)) 157 157 return 0; 158 158 } 159 else if (!strcmp(p Digest->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_MD4))160 { 161 if (!strcmp(p EncryptedDigest->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_MD4_WITH_RSA))159 else if (!strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_MD4)) 160 { 161 if (!strcmp(pszEncryptedDigestOid, RTCRX509ALGORITHMIDENTIFIERID_MD4_WITH_RSA)) 162 162 return 0; 163 163 } 164 else if (!strcmp(p Digest->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA384))165 { 166 if (!strcmp(p EncryptedDigest->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA384_WITH_RSA))164 else if (!strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA384)) 165 { 166 if (!strcmp(pszEncryptedDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA384_WITH_RSA)) 167 167 return 0; 168 168 } 169 else if (!strcmp(p Digest->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA224))170 { 171 if (!strcmp(p EncryptedDigest->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA224_WITH_RSA))169 else if (!strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA224)) 170 { 171 if (!strcmp(pszEncryptedDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA224_WITH_RSA)) 172 172 return 0; 173 173 } 174 else if (!strcmp(p Digest->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_WHIRLPOOL))174 else if (!strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_WHIRLPOOL)) 175 175 { 176 176 /* ?? */ … … 179 179 return -1; 180 180 return 1; 181 } 182 183 RTDECL(int) RTCrX509AlgorithmIdentifier_CompareDigestAndEncryptedDigest(PCRTCRX509ALGORITHMIDENTIFIER pDigest, 184 PCRTCRX509ALGORITHMIDENTIFIER pEncryptedDigest) 185 { 186 return RTCrX509AlgorithmIdentifier_CompareDigestOidAndEncryptedDigestOid(pDigest->Algorithm.szObjId, 187 pEncryptedDigest->Algorithm.szObjId); 188 } 189 190 191 RTDECL(const char *) RTCrX509AlgorithmIdentifier_CombineEncryptionOidAndDigestOid(const char *pszEncryptionOid, 192 const char *pszDigestOid) 193 { 194 /* RSA: */ 195 if (!strcmp(pszEncryptionOid, RTCRX509ALGORITHMIDENTIFIERID_RSA)) 196 { 197 if ( !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_MD5) 198 || !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_MD5_WITH_RSA)) 199 return RTCRX509ALGORITHMIDENTIFIERID_MD5_WITH_RSA; 200 if ( !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA1) 201 || !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA1_WITH_RSA)) 202 return RTCRX509ALGORITHMIDENTIFIERID_SHA1_WITH_RSA; 203 if ( !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA256) 204 || !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA256_WITH_RSA)) 205 return RTCRX509ALGORITHMIDENTIFIERID_SHA256_WITH_RSA; 206 if ( !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA512) 207 || !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA512_WITH_RSA)) 208 return RTCRX509ALGORITHMIDENTIFIERID_SHA512_WITH_RSA; 209 if ( !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_MD2) 210 || !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_MD2_WITH_RSA)) 211 return RTCRX509ALGORITHMIDENTIFIERID_MD2_WITH_RSA; 212 if ( !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_MD4) 213 || !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_MD4_WITH_RSA)) 214 return RTCRX509ALGORITHMIDENTIFIERID_MD4_WITH_RSA; 215 if ( !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA384) 216 || !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA384_WITH_RSA)) 217 return RTCRX509ALGORITHMIDENTIFIERID_SHA384_WITH_RSA; 218 if ( !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA224) 219 || !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA224_WITH_RSA)) 220 return RTCRX509ALGORITHMIDENTIFIERID_SHA224_WITH_RSA; 221 222 /* if (!strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_WHIRLPOOL)) 223 return ???; */ 224 } 225 else if (RTCrX509AlgorithmIdentifier_CompareDigestOidAndEncryptedDigestOid(pszDigestOid, pszEncryptionOid) == 0) 226 return pszEncryptionOid; 227 228 AssertMsgFailed(("enc=%s hash=%s\n", pszEncryptionOid, pszDigestOid)); 229 return NULL; 230 } 231 232 233 RTDECL(const char *) RTCrX509AlgorithmIdentifier_CombineEncryptionAndDigest(PCRTCRX509ALGORITHMIDENTIFIER pEncryption, 234 PCRTCRX509ALGORITHMIDENTIFIER pDigest) 235 { 236 return RTCrX509AlgorithmIdentifier_CombineEncryptionOidAndDigestOid(pEncryption->Algorithm.szObjId, 237 pDigest->Algorithm.szObjId); 181 238 } 182 239
Note:
See TracChangeset
for help on using the changeset viewer.