• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ EVP_PKEY_type函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中EVP_PKEY_type函数的典型用法代码示例。如果您正苦于以下问题:C++ EVP_PKEY_type函数的具体用法?C++ EVP_PKEY_type怎么用?C++ EVP_PKEY_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了EVP_PKEY_type函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: EVP_PKEY_set_alias_type

int EVP_PKEY_set_alias_type(EVP_PKEY *pkey, int type)
{
    if (pkey->type == type) {
        return 1; /* it already is that type */
    }

    /*
     * The application is requesting to alias this to a different pkey type,
     * but not one that resolves to the base type.
     */
    if (EVP_PKEY_type(type) != EVP_PKEY_base_id(pkey)) {
        EVPerr(EVP_F_EVP_PKEY_SET_ALIAS_TYPE, EVP_R_UNSUPPORTED_ALGORITHM);
        return 0;
    }

    pkey->type = type;
    return 1;
}
开发者ID:EiffelSoftware,项目名称:EiffelStudio,代码行数:18,代码来源:p_lib.c


示例2: ossl_ec_new

VALUE ossl_ec_new(EVP_PKEY *pkey)
{
    VALUE obj;

    if (!pkey) {
	obj = ec_instance(cEC, EC_KEY_new());
    } else {
	if (EVP_PKEY_type(pkey->type) != EVP_PKEY_EC) {
	    ossl_raise(rb_eTypeError, "Not a EC key!");
	}
	WrapPKey(cEC, obj, pkey);
    }
    if (obj == Qfalse) {
	ossl_raise(eECError, NULL);
    }

    return obj;
}
开发者ID:fi8on,项目名称:ruby,代码行数:18,代码来源:ossl_pkey_ec.c


示例3: switch

QString pki_key::getTypeString()
{
	QString type;
	switch (EVP_PKEY_type(key->type)) {
		case EVP_PKEY_RSA:
			type = "RSA";
			break;
		case EVP_PKEY_DSA:
			type = "DSA";
			break;
		case EVP_PKEY_EC:
			type = "EC";
			break;
		default:
			type = "---";
	}
	return type;
}
开发者ID:jbfavre,项目名称:xca,代码行数:18,代码来源:pki_key.cpp


示例4: pkcs8

/* static */
Key* Key::ImportKey(const AuthorizationSet& key_description, keymaster_key_format_t key_format,
                    const uint8_t* key_data, size_t key_data_length, const Logger& logger,
                    keymaster_error_t* error) {
    *error = KM_ERROR_OK;

    if (key_data == NULL || key_data_length <= 0) {
        *error = KM_ERROR_INVALID_KEY_BLOB;
        return NULL;
    }

    if (key_format != KM_KEY_FORMAT_PKCS8) {
        *error = KM_ERROR_UNSUPPORTED_KEY_FORMAT;
        return NULL;
    }

    UniquePtr<PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO_Delete> pkcs8(
        d2i_PKCS8_PRIV_KEY_INFO(NULL, &key_data, key_data_length));
    if (pkcs8.get() == NULL) {
        *error = KM_ERROR_MEMORY_ALLOCATION_FAILED;
        return NULL;
    }

    UniquePtr<EVP_PKEY, EVP_PKEY_Delete> pkey(EVP_PKCS82PKEY(pkcs8.get()));
    if (pkey.get() == NULL) {
        *error = KM_ERROR_INVALID_KEY_BLOB;
        return NULL;
    }

    UniquePtr<Key> key;
    switch (EVP_PKEY_type(pkey->type)) {
    case EVP_PKEY_RSA:
        return RsaKey::ImportKey(key_description, pkey.get(), logger, error);
    case EVP_PKEY_DSA:
        return DsaKey::ImportKey(key_description, pkey.get(), logger, error);
    case EVP_PKEY_EC:
        return EcdsaKey::ImportKey(key_description, pkey.get(), logger, error);
    default:
        *error = KM_ERROR_UNSUPPORTED_ALGORITHM;
        return NULL;
    }

    *error = KM_ERROR_UNIMPLEMENTED;
    return NULL;
}
开发者ID:PDi-Communication-Systems-Inc,项目名称:lollipop_system_keymaster,代码行数:45,代码来源:key.cpp


示例5: ossl_dh_new

VALUE
ossl_dh_new(EVP_PKEY *pkey)
{
    VALUE obj;

    if (!pkey) {
	obj = dh_instance(cDH, DH_new());
    } else {
	if (EVP_PKEY_type(pkey->type) != EVP_PKEY_DH) {
	    ossl_raise(rb_eTypeError, "Not a DH key!");
	}
	WrapPKey(cDH, obj, pkey);
    }
    if (obj == Qfalse) {
	ossl_raise(eDHError, NULL);
    }

    return obj;
}
开发者ID:0x00evil,项目名称:ruby,代码行数:19,代码来源:ossl_pkey_dh.c


示例6: load_and_print_pubkey

int load_and_print_pubkey(FILE* pemFile, int version) {
  assert(pemFile);

  EVP_PKEY* pubkey = PEM_read_PUBKEY(pemFile, NULL, NULL, NULL);
  if (!pubkey) {
    fprintf(stderr, "error: PEM_read_PUBKEY() failed.\n");
    return 1;
  }

  if (EVP_PKEY_type(pubkey->type) != EVP_PKEY_EC) {
    fprintf(stderr, "error: PEM does not contain an EC key.\n");
    EVP_PKEY_free(pubkey);
    return 1;
  }
  
  int result = extract_and_print_eckey(pubkey, version);
  EVP_PKEY_free(pubkey);
  return result;
}
开发者ID:0963682490,项目名称:omaha,代码行数:19,代码来源:eckeytool.c


示例7: PKI_sign_RSA

SEXP PKI_sign_RSA(SEXP what, SEXP sMD, SEXP sKey) {
    SEXP res;
    int md = asInteger(sMD), type;
    EVP_PKEY *key;
    RSA *rsa;
    unsigned int siglen = sizeof(buf);
  switch (md) {
    case PKI_MD5:
      type = NID_md5;
      break;
    case PKI_SHA1:
      type = NID_sha1;
      break;
    case PKI_SHA256:
      type = NID_sha256;
      break;
    default:
      Rf_error("unsupported hash type");
  }
    if (TYPEOF(what) != RAWSXP ||
	(md == PKI_MD5 && LENGTH(what) != MD5_DIGEST_LENGTH) ||
	(md == PKI_SHA1 && LENGTH(what) != SHA_DIGEST_LENGTH) ||
  (md == PKI_SHA256 && LENGTH(what) != SHA256_DIGEST_LENGTH))
	Rf_error("invalid hash");
    if (!inherits(sKey, "private.key"))
	Rf_error("key must be RSA private key");
    key = (EVP_PKEY*) R_ExternalPtrAddr(sKey);
    if (!key)
	Rf_error("NULL key");
    PKI_init();
    if (EVP_PKEY_type(key->type) != EVP_PKEY_RSA)
	Rf_error("key must be RSA private key");
    rsa = EVP_PKEY_get1_RSA(key);
    if (!rsa)
	Rf_error("%s", ERR_error_string(ERR_get_error(), NULL));
    if (RSA_sign(type,
		 (const unsigned char*) RAW(what), LENGTH(what),
		 (unsigned char *) buf, &siglen, rsa) != 1)
	Rf_error("%s", ERR_error_string(ERR_get_error(), NULL));
    res = allocVector(RAWSXP, siglen);
    memcpy(RAW(res), buf, siglen);
    return res;
}
开发者ID:rOpenSec,项目名称:PKI,代码行数:43,代码来源:pki-x509.c


示例8: ASN1err

EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,
	     long length)
	{
	EVP_PKEY *ret;
	
	if ((a == NULL) || (*a == NULL))
		{
		if ((ret=EVP_PKEY_new()) == NULL)
			{
			ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_EVP_LIB);
			return(NULL);
			}
		}
	else	ret= *a;

	ret->save_type=type;
	ret->type=EVP_PKEY_type(type);
	switch (ret->type)
		{
#ifndef OPENSSL_NO_RSA
	case EVP_PKEY_RSA:
		if ((ret->pkey.rsa=d2i_RSAPublicKey(NULL,
			(const unsigned char **)pp,length)) == NULL) /* TMP UGLY CAST */
			{
			ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_ASN1_LIB);
			goto err;
			}
		break;
#endif

	default:
		ASN1err(ASN1_F_D2I_PUBLICKEY,ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE);
		goto err;
		/* break; */
		}
	if (a != NULL) (*a)=ret;
	return(ret);
err:
	if ((ret != NULL) && ((a == NULL) || (*a != ret)))
			EVP_PKEY_free(ret);
	return(NULL);
	}
开发者ID:Aorjoa,项目名称:bootloader,代码行数:42,代码来源:d2i_pu.c


示例9: meth_pubkey

/**
 * Extract public key in PEM format.
 */
static int meth_pubkey(lua_State* L)
{
  char* data;
  long bytes;
  int ret = 1;
  X509* cert = lsec_checkx509(L, 1);
  BIO *bio = BIO_new(BIO_s_mem());
  EVP_PKEY *pkey = X509_get_pubkey(cert);
  if(PEM_write_bio_PUBKEY(bio, pkey)) {
    bytes = BIO_get_mem_data(bio, &data);
    if (bytes > 0) {
      lua_pushlstring(L, data, bytes);
      switch(EVP_PKEY_type(pkey->type)) {
        case EVP_PKEY_RSA:
          lua_pushstring(L, "RSA");
          break;
        case EVP_PKEY_DSA:
          lua_pushstring(L, "DSA");
          break;
        case EVP_PKEY_DH:
          lua_pushstring(L, "DH");
          break;
        case EVP_PKEY_EC:
          lua_pushstring(L, "EC");
          break;
        default:
          lua_pushstring(L, "Unknown");
          break;
      }
      lua_pushinteger(L, EVP_PKEY_bits(pkey));
      ret = 3;
    }
    else
      lua_pushnil(L);
  }
  else
    lua_pushnil(L);
  /* Cleanup */
  BIO_free(bio);
  EVP_PKEY_free(pkey);
  return ret;
}
开发者ID:Chingliu,项目名称:luasec,代码行数:45,代码来源:x509.c


示例10: syslog_sign_init

int
syslog_sign_init()
{
    SSL *ssl;

    sign_global_conf =  EVP_MD_CTX_create();
    EVP_MD_CTX_init(sign_global_conf);

    if (ssl = SSL_new(ssl_global_conf)) {
        dprintf("Try to get keys from TLS X.509 cert...\n");

        if (!(xcert = SSL_get_certificate(ssl))) {
            logerror("SSL_get_certificate() failed");
            SSL_free(ssl);
            return EXIT_FAILURE;
        }
        if (!(eprivkey = SSL_get_privatekey(ssl))) {
            logerror("SSL_get_privatekey() failed");
            SSL_free(ssl);
            return EXIT_FAILURE;
        }
        if (!(epubkey = X509_get_pubkey(xcert))) {
            logerror("X509_get_pubkey() failed");
            SSL_free(ssl);
            return EXIT_FAILURE;
        }
    }

    SSL_free(ssl);

    if (EVP_PKEY_DSA != EVP_PKEY_type(epubkey->type)) {
        dprintf("X.509 cert has no DSA key\n");
        EVP_PKEY_free(epubkey);
        eprivkey = NULL;
        epubkey = NULL;
    } else {
        dprintf("Got public and private key "
                "from X.509 --> use type PKIX\n");

        sign_method = EVP_dss1();
    }
}
开发者ID:haad,项目名称:syslogd,代码行数:42,代码来源:sign.c


示例11: PKI_X509_KEYPAIR_VALUE_get_algor

PKI_ALGOR * PKI_X509_KEYPAIR_VALUE_get_algor ( PKI_X509_KEYPAIR_VALUE *pVal )
{
	PKI_ALGOR *ret = NULL;

	int size = -1;
	int algId = -1;

	size = PKI_X509_KEYPAIR_VALUE_get_size(pVal);
	if (size <= 0) PKI_ERROR(PKI_ERR_GENERAL, "Key size is 0!");

	switch (EVP_PKEY_type(pVal->type))
	{
		case EVP_PKEY_DSA:
			algId = PKI_ALGOR_DSA_SHA1;
			break;

		case EVP_PKEY_RSA:
			algId = PKI_ALGOR_RSA_SHA256;
			break;

#ifdef ENABLE_ECDSA
		case EVP_PKEY_EC:
			if ( size < 256 ) {
				algId = PKI_ALGOR_ECDSA_SHA1;
			} else if ( size < 384 ) {
				algId = PKI_ALGOR_ECDSA_SHA256;
			} else if ( size < 512 ) {
				algId = PKI_ALGOR_ECDSA_SHA384;
			} else {
				algId = PKI_ALGOR_ECDSA_SHA512;
			};
			break;
#endif

		default:
			return ret;
	};

	if( algId > 0 ) ret = PKI_ALGOR_get ( algId );

	return ret;
};
开发者ID:Brenhilt,项目名称:libpki,代码行数:42,代码来源:pki_keypair.c


示例12: getPrivKeyType

int getPrivKeyType(EVP_PKEY *pkey)
{
  int rValue = CERT_OBJECT_MAX_OBJECT;

  switch (EVP_PKEY_type(pkey->type))
    {
    case EVP_PKEY_RSA:
      rValue = CERT_OBJECT_RSA_PRIVATE_KEY;
      break;

    case EVP_PKEY_DSA:
      rValue = CERT_OBJECT_DSA_PRIVATE_KEY;
      break;
    case EVP_PKEY_EC:
      rValue = CERT_OBJECT_EC_PRIVATE_KEY;
      break;
    }

  return rValue;
}
开发者ID:openwebos,项目名称:pmcertificatemgr,代码行数:20,代码来源:cert_utils.c


示例13: TEST_P

TEST_P(KeymasterGenerateECTest, GenerateKeyPair_EC_Success) {
    keymaster_keypair_t key_type = TYPE_EC;
    keymaster_ec_keygen_params_t params = {
            .field_size = GetParam(),
    };

    uint8_t* key_blob;
    size_t key_blob_length;

    ASSERT_EQ(0,
            sDevice->generate_keypair(sDevice, key_type, &params, &key_blob, &key_blob_length))
            << "Should generate an EC key with " << GetParam() << " field size";
    UniqueKey key(&sDevice, key_blob, key_blob_length);

    uint8_t* x509_data = NULL;
    size_t x509_data_length;
    ASSERT_EQ(0,
            sDevice->get_keypair_public(sDevice, key_blob, key_blob_length,
                    &x509_data, &x509_data_length))
            << "Should be able to retrieve EC public key successfully";
    UniqueBlob x509_blob(x509_data, x509_data_length);
    ASSERT_FALSE(x509_blob.get() == NULL)
            << "X509 data should be allocated";

    const unsigned char *tmp = static_cast<const unsigned char*>(x509_blob.get());
    Unique_EVP_PKEY actual(d2i_PUBKEY((EVP_PKEY**) NULL, &tmp,
            static_cast<long>(x509_blob.length())));

    ASSERT_EQ(EVP_PKEY_EC, EVP_PKEY_type(actual.get()->type))
            << "Generated key type should be of type EC";

    Unique_EC_KEY ecKey(EVP_PKEY_get1_EC_KEY(actual.get()));
    ASSERT_FALSE(ecKey.get() == NULL)
            << "Should be able to extract EC key from EVP_PKEY";

    ASSERT_FALSE(EC_KEY_get0_group(ecKey.get()) == NULL)
            << "EC key should have a EC_GROUP";

    ASSERT_TRUE(EC_KEY_check_key(ecKey.get()))
            << "EC key should check correctly";
}
开发者ID:MIPS,项目名称:hardware-libhardware,代码行数:41,代码来源:keymaster_test.cpp


示例14: PKI_verify_RSA

SEXP PKI_verify_RSA(SEXP what, SEXP sMD, SEXP sKey, SEXP sig) {
    int md = asInteger(sMD), type;
    EVP_PKEY *key;
    RSA *rsa;
    switch (md) {
    case PKI_MD5:
  type = NID_md5;
  break;
    case PKI_SHA1:
  type = NID_sha1;
  break;
    case PKI_SHA256:
  type = NID_sha256;
  break;
    default:
  Rf_error("unsupported hash type");
  }
    if (TYPEOF(what) != RAWSXP ||
  (md == PKI_MD5 && LENGTH(what) != MD5_DIGEST_LENGTH) ||
  (md == PKI_SHA1 && LENGTH(what) != SHA_DIGEST_LENGTH) ||
  (md == PKI_SHA256 && LENGTH(what) != SHA256_DIGEST_LENGTH))
	Rf_error("invalid hash");
    if (!inherits(sKey, "public.key") && !inherits(sKey, "private.key"))
	Rf_error("key must be RSA public or private key");
    key = (EVP_PKEY*) R_ExternalPtrAddr(sKey);
    if (!key)
	Rf_error("NULL key");
    if (EVP_PKEY_type(key->type) != EVP_PKEY_RSA)
	Rf_error("key must be RSA public or private key");
    rsa = EVP_PKEY_get1_RSA(key);
    if (!rsa)
	Rf_error("%s", ERR_error_string(ERR_get_error(), NULL));
    return
	ScalarLogical( /* FIXME: sig is not const in RSA_verify - that is odd so in theory in may modify sig ... */
		      (RSA_verify(type,
				  (const unsigned char*) RAW(what), LENGTH(what),
				  (unsigned char *) RAW(sig), LENGTH(sig), rsa) == 1)
		      ? TRUE : FALSE);
}
开发者ID:rOpenSec,项目名称:PKI,代码行数:39,代码来源:pki-x509.c


示例15: switch

QSslKey SafetPKCS12::keyFromEVP( EVP_PKEY * evp )
{
    EVP_PKEY *key = (EVP_PKEY*)evp;
    unsigned char *data = NULL;
    int len = 0;
    QSsl::KeyAlgorithm alg;
    QSsl::KeyType type;

    switch( EVP_PKEY_type( key->type ) )
    {
        case EVP_PKEY_RSA:
        {
            RSA *rsa = EVP_PKEY_get1_RSA( key );
            alg = QSsl::Rsa;
            type = rsa->d ? QSsl::PrivateKey : QSsl::PublicKey;
            len = rsa->d ? i2d_RSAPrivateKey( rsa, &data ) : i2d_RSAPublicKey( rsa, &data );
            RSA_free( rsa );
            break;
        }
        case EVP_PKEY_DSA:
        {
            DSA *dsa = EVP_PKEY_get1_DSA( key );
            alg = QSsl::Dsa;
            type = dsa->priv_key ? QSsl::PrivateKey : QSsl::PublicKey;
            len = dsa->priv_key ? i2d_DSAPrivateKey( dsa, &data ) : i2d_DSAPublicKey( dsa, &data );
            DSA_free( dsa );
            break;
        }
        default: break;
    }

    QSslKey k;
    if( len > 0 )
        k = QSslKey( QByteArray( (char*)data, len ), alg, QSsl::Der, type );
    OPENSSL_free( data );

    return k;
}
开发者ID:Cenditel,项目名称:pysafet,代码行数:38,代码来源:safetpkcs12.cpp


示例16: __attribute__

__attribute__((visibility("default"))) int openssl_sign_data(
    const keymaster0_device_t*, const void* params, const uint8_t* keyBlob,
    const size_t keyBlobLength, const uint8_t* data, const size_t dataLength, uint8_t** signedData,
    size_t* signedDataLength) {
    if (data == NULL) {
        ALOGW("input data to sign == NULL");
        return -1;
    } else if (signedData == NULL || signedDataLength == NULL) {
        ALOGW("output signature buffer == NULL");
        return -1;
    }

    Unique_EVP_PKEY pkey(unwrap_key(keyBlob, keyBlobLength));
    if (pkey.get() == NULL) {
        return -1;
    }

    int type = EVP_PKEY_type(pkey->type);
    if (type == EVP_PKEY_DSA) {
        const keymaster_dsa_sign_params_t* sign_params =
            reinterpret_cast<const keymaster_dsa_sign_params_t*>(params);
        return sign_dsa(pkey.get(), const_cast<keymaster_dsa_sign_params_t*>(sign_params), data,
                        dataLength, signedData, signedDataLength);
    } else if (type == EVP_PKEY_EC) {
        const keymaster_ec_sign_params_t* sign_params =
            reinterpret_cast<const keymaster_ec_sign_params_t*>(params);
        return sign_ec(pkey.get(), const_cast<keymaster_ec_sign_params_t*>(sign_params), data,
                       dataLength, signedData, signedDataLength);
    } else if (type == EVP_PKEY_RSA) {
        const keymaster_rsa_sign_params_t* sign_params =
            reinterpret_cast<const keymaster_rsa_sign_params_t*>(params);
        return sign_rsa(pkey.get(), const_cast<keymaster_rsa_sign_params_t*>(sign_params), data,
                        dataLength, signedData, signedDataLength);
    } else {
        ALOGW("Unsupported key type");
        return -1;
    }
}
开发者ID:LordNerevar,项目名称:system_security,代码行数:38,代码来源:keymaster_openssl.cpp


示例17: ep_crypto_keytype_fromkey

int
ep_crypto_keytype_fromkey(EP_CRYPTO_KEY *key)
{
	int i = EVP_PKEY_type(key->type);

	switch (i)
	{
	  case EVP_PKEY_RSA:
		return EP_CRYPTO_KEYTYPE_RSA;

	  case EVP_PKEY_DSA:
		return EP_CRYPTO_KEYTYPE_DSA;

	  case EVP_PKEY_DH:
		return EP_CRYPTO_KEYTYPE_DH;

	  case EVP_PKEY_EC:
		return EP_CRYPTO_KEYTYPE_EC;

	  default:
		return EP_CRYPTO_KEYTYPE_UNKNOWN;
	}
}
开发者ID:jugador87,项目名称:gdp,代码行数:23,代码来源:ep_crypto_key.c


示例18: ldns_pkey_is_ecdsa

static int
ldns_pkey_is_ecdsa(EVP_PKEY* pkey)
{
        EC_KEY* ec;
        const EC_GROUP* g;
        if(EVP_PKEY_type(pkey->type) != EVP_PKEY_EC)
                return 0;
        ec = EVP_PKEY_get1_EC_KEY(pkey);
        g = EC_KEY_get0_group(ec);
        if(!g) {
                EC_KEY_free(ec);
                return 0;
        }
        if(EC_GROUP_get_curve_name(g) == NID_secp224r1 ||
                EC_GROUP_get_curve_name(g) == NID_X9_62_prime256v1 ||
                EC_GROUP_get_curve_name(g) == NID_secp384r1) {
                EC_KEY_free(ec);
                return 1;
        }
        /* downref the eckey, the original is still inside the pkey */
        EC_KEY_free(ec);
        return 0;
}
开发者ID:mbuij,项目名称:ldns-cga-tsig,代码行数:23,代码来源:dnssec_sign.c


示例19: throw

/**
 * Verify signature with RSA public key from X.509 certificate.
 *
 * @param digestMethod digest method (e.g NID_sha1 for SHA1, see openssl/obj_mac.h).
 * @param digest digest value, this value is compared with the digest value decrypted from the <code>signature</code>.
 * @param signature signature value, this value is decrypted to get the digest and compared with
 *        the digest value provided in <code>digest</code>.
 * @return returns <code>true</code> if the signature value matches with the digest, otherwise <code>false</code>
 *         is returned.
 * @throws IOException throws exception if X.509 certificate is not missing or does not have a RSA public key.
 */
bool digidoc::RSACrypt::verify(int digestMethod, std::vector<unsigned char> digest, std::vector<unsigned char> signature) throw(IOException)
{
    // Check that X.509 certificate is set.
    if(cert == NULL)
    {
        THROW_IOEXCEPTION("X.509 certificate parameter is not set in RSACrypt, can not verify signature.");
    }

    // Extract RSA public key from X.509 certificate.
    X509Cert x509(cert);
    EVP_PKEY* key = x509.getPublicKey();
    if(EVP_PKEY_type(key->type) != EVP_PKEY_RSA)
    {
        EVP_PKEY_free(key);
        THROW_IOEXCEPTION("Certificate '%s' does not have a RSA public key, can not verify signature.", x509.getSubject().c_str());
    }
    RSA* publicKey = EVP_PKEY_get1_RSA(key);

    // Verify signature with RSA public key.
    int result = RSA_verify(digestMethod, &digest[0], digest.size(), &signature[0], signature.size(), publicKey);
    RSA_free(publicKey);
    EVP_PKEY_free(key);
    return (result == 1);
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:35,代码来源:RSACrypt.cpp


示例20: PKI_decrypt

SEXP PKI_decrypt(SEXP what, SEXP sKey) {
    SEXP res;
    EVP_PKEY *key;
    RSA *rsa;
    int len;
    if (TYPEOF(what) != RAWSXP)
	Rf_error("invalid payload to sign - must be a raw vector");
    if (!inherits(sKey, "private.key"))
	Rf_error("invalid key object");
    key = (EVP_PKEY*) R_ExternalPtrAddr(sKey);
    if (!key)
	Rf_error("NULL key");
    if (EVP_PKEY_type(key->type) != EVP_PKEY_RSA)
	Rf_error("Sorry only RSA keys are supported at this point");
    rsa = EVP_PKEY_get1_RSA(key);
    if (!rsa)
	Rf_error("%s", ERR_error_string(ERR_get_error(), NULL));
    len = RSA_private_decrypt(LENGTH(what), RAW(what), (unsigned char*) buf, rsa, RSA_PKCS1_PADDING);
    if (len < 0)
	Rf_error("%s", ERR_error_string(ERR_get_error(), NULL));
    res = allocVector(RAWSXP, len);
    memcpy(RAW(res), buf, len);
    return res;
}
开发者ID:prateek05,项目名称:PKI,代码行数:24,代码来源:pki-x509.c



注:本文中的EVP_PKEY_type函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ EVP_VerifyFinal函数代码示例发布时间:2022-05-30
下一篇:
C++ EVP_PKEY_size函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap