int tls13_check_message_type(SSL *ssl, int type) { if (ssl->s3->tmp.message_type != type) { ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE); OPENSSL_PUT_ERROR(SSL, SSL_R_UNEXPECTED_MESSAGE); ERR_add_error_dataf("got type %d, wanted type %d", ssl->s3->tmp.message_type, type); return 0; } return 1; }
static EVP_PKEY_CTX *evp_pkey_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id) { EVP_PKEY_CTX *ret; const EVP_PKEY_METHOD *pmeth; if (id == -1) { if (!pkey || !pkey->ameth) { return NULL; } id = pkey->ameth->pkey_id; } pmeth = evp_pkey_meth_find(id); if (pmeth == NULL) { OPENSSL_PUT_ERROR(EVP, evp_pkey_ctx_new, EVP_R_UNSUPPORTED_ALGORITHM); const char *name = OBJ_nid2sn(id); ERR_add_error_dataf("algorithm %d (%s)", id, name); return NULL; } ret = OPENSSL_malloc(sizeof(EVP_PKEY_CTX)); if (!ret) { OPENSSL_PUT_ERROR(EVP, evp_pkey_ctx_new, ERR_R_MALLOC_FAILURE); return NULL; } memset(ret, 0, sizeof(EVP_PKEY_CTX)); ret->engine = e; ret->pmeth = pmeth; ret->operation = EVP_PKEY_OP_UNDEFINED; if (pkey) { ret->pkey = EVP_PKEY_dup(pkey); } if (pmeth->init) { if (pmeth->init(ret) <= 0) { if (pkey) { EVP_PKEY_free(ret->pkey); } OPENSSL_free(ret); return NULL; } } return ret; }
int EVP_PKEY_set_type(EVP_PKEY *pkey, int type) { const EVP_PKEY_ASN1_METHOD *ameth; if (pkey && pkey->pkey.ptr) { free_it(pkey); } ameth = evp_pkey_asn1_find(type); if (ameth == NULL) { OPENSSL_PUT_ERROR(EVP, EVP_R_UNSUPPORTED_ALGORITHM); ERR_add_error_dataf("algorithm %d", type); return 0; } if (pkey) { pkey->ameth = ameth; pkey->type = pkey->ameth->pkey_id; } return 1; }