Public Member Functions | |
verify_implementation (EVP_PKEY *pkey) | |
~verify_implementation () | |
int | operator() (const DDS::OctetSeq &src, const std::vector< const DDS::OctetSeq * > &expected_contents) |
Private Attributes | |
EVP_PKEY * | public_key |
EVP_MD_CTX * | md_ctx |
EVP_PKEY_CTX * | pkey_ctx |
Definition at line 173 of file Certificate.cpp.
OpenDDS::Security::SSL::verify_implementation::verify_implementation | ( | EVP_PKEY * | pkey | ) | [inline, explicit] |
Definition at line 176 of file Certificate.cpp.
00177 : public_key(pkey), md_ctx(NULL), pkey_ctx(NULL) 00178 { 00179 }
OpenDDS::Security::SSL::verify_implementation::~verify_implementation | ( | ) | [inline] |
Definition at line 180 of file Certificate.cpp.
References EVP_MD_CTX_free, and md_ctx.
00180 { EVP_MD_CTX_free(md_ctx); }
int OpenDDS::Security::SSL::verify_implementation::operator() | ( | const DDS::OctetSeq & | src, | |
const std::vector< const DDS::OctetSeq * > & | expected_contents | |||
) | [inline] |
Definition at line 182 of file Certificate.cpp.
References EVP_MD_CTX_new, md_ctx, OPENDDS_SSL_LOG_ERR, pkey_ctx, and public_key.
00184 { 00185 if (!public_key) return 1; 00186 00187 int pk_id = 0; 00188 std::vector<const DDS::OctetSeq*>::const_iterator i, n; 00189 00190 md_ctx = EVP_MD_CTX_new(); 00191 if (!md_ctx) { 00192 OPENDDS_SSL_LOG_ERR("EVP_MD_CTX_new failed"); 00193 return 1; 00194 } 00195 00196 EVP_MD_CTX_init(md_ctx); 00197 00198 if (1 != EVP_DigestVerifyInit(md_ctx, &pkey_ctx, EVP_sha256(), NULL, 00199 public_key)) { 00200 OPENDDS_SSL_LOG_ERR("EVP_DigestVerifyInit failed"); 00201 return 1; 00202 } 00203 00204 // Determine which signature type is being verified 00205 pk_id = EVP_PKEY_id(public_key); 00206 00207 if (pk_id == EVP_PKEY_RSA) { 00208 if (1 != 00209 EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING)) { 00210 OPENDDS_SSL_LOG_ERR("EVP_PKEY_CTX_set_rsa_padding failed"); 00211 return 1; 00212 } 00213 00214 if (1 != EVP_PKEY_CTX_set_rsa_mgf1_md(pkey_ctx, EVP_sha256())) { 00215 OPENDDS_SSL_LOG_ERR("EVP_PKEY_CTX_set_rsa_mgf1_md failed"); 00216 return 1; 00217 } 00218 } 00219 00220 n = expected_contents.end(); 00221 for (i = expected_contents.begin(); i != n; ++i) { 00222 if ((*i)->length() > 0) { 00223 if (1 != EVP_DigestVerifyUpdate(md_ctx, (*i)->get_buffer(), 00224 (*i)->length())) { 00225 OPENDDS_SSL_LOG_ERR("EVP_DigestVerifyUpdate failed"); 00226 return 1; 00227 } 00228 } 00229 } 00230 00231 int err = EVP_DigestVerifyFinal(md_ctx, src.get_buffer(), src.length()); 00232 if (0 == err) { 00233 return 1; // Verification failed, but no error occurred 00234 00235 } else if (1 != err) { 00236 OPENDDS_SSL_LOG_ERR("EVP_DigestVerifyFinal failed"); 00237 return 1; 00238 } 00239 00240 return 0; 00241 }
EVP_MD_CTX* OpenDDS::Security::SSL::verify_implementation::md_ctx [private] |
Definition at line 245 of file Certificate.cpp.
Referenced by operator()(), and ~verify_implementation().
EVP_PKEY_CTX* OpenDDS::Security::SSL::verify_implementation::pkey_ctx [private] |
Definition at line 246 of file Certificate.cpp.
Referenced by operator()().
Definition at line 244 of file Certificate.cpp.
Referenced by operator()().