您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ EVP_aes_192_cbc函数代码示例

51自学网 2021-06-01 20:35:36
  C++
这篇教程C++ EVP_aes_192_cbc函数代码示例写得很实用,希望能帮到您。

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

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

示例1: SSL_library_init

EXPORT_C int SSL_library_init(void)	{//#ifdef EMULATOR	//	InitSSLWsdVar();	//#endif	#ifndef OPENSSL_NO_DES	EVP_add_cipher(EVP_des_cbc());	EVP_add_cipher(EVP_des_ede3_cbc());#endif#ifndef OPENSSL_NO_IDEA	EVP_add_cipher(EVP_idea_cbc());#endif#ifndef OPENSSL_NO_RC4	EVP_add_cipher(EVP_rc4());#endif  #ifndef OPENSSL_NO_RC2	EVP_add_cipher(EVP_rc2_cbc());#endif#ifndef OPENSSL_NO_AES	EVP_add_cipher(EVP_aes_128_cbc());	EVP_add_cipher(EVP_aes_192_cbc());	EVP_add_cipher(EVP_aes_256_cbc());#endif#ifndef OPENSSL_NO_MD2	EVP_add_digest(EVP_md2());#endif#ifndef OPENSSL_NO_MD5	EVP_add_digest(EVP_md5());	EVP_add_digest_alias(SN_md5,"ssl2-md5");	EVP_add_digest_alias(SN_md5,"ssl3-md5");#endif#ifndef OPENSSL_NO_SHA	EVP_add_digest(EVP_sha1()); /* RSA with sha1 */	EVP_add_digest_alias(SN_sha1,"ssl3-sha1");	EVP_add_digest_alias(SN_sha1WithRSAEncryption,SN_sha1WithRSA);#endif#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_DSA)	EVP_add_digest(EVP_dss1()); /* DSA with sha1 */	EVP_add_digest_alias(SN_dsaWithSHA1,SN_dsaWithSHA1_2);	EVP_add_digest_alias(SN_dsaWithSHA1,"DSS1");	EVP_add_digest_alias(SN_dsaWithSHA1,"dss1");#endif#ifndef OPENSSL_NO_ECDSA	EVP_add_digest(EVP_ecdsa());#endif	/* If you want support for phased out ciphers, add the following */#if 0	EVP_add_digest(EVP_sha());	EVP_add_digest(EVP_dss());#endif#ifndef OPENSSL_NO_COMP	/* This will initialise the built-in compression algorithms.	   The value returned is a STACK_OF(SSL_COMP), but that can	   be discarded safely */	(void)SSL_COMP_get_compression_methods();#endif	/* initialize cipher/digest methods table */	ssl_load_ciphers();	return(1);	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:60,


示例2: EVP_aes_128_cbc

const EVP_CIPHER *OpensslAES::getEvpCipher() const{    if (m_type == TypeAes128 && m_mode == ModeCbc) {        return EVP_aes_128_cbc();    } else if (m_type == TypeAes128 && m_mode == ModeCfb) {        return EVP_aes_128_cfb128();    } else if (m_type == TypeAes128 && m_mode == ModeEcb) {        return EVP_aes_128_ecb();    } else if (m_type == TypeAes128 && m_mode == ModeOfb) {        return EVP_aes_128_ofb();    } else if (m_type == TypeAes192 && m_mode == ModeCbc) {        return EVP_aes_192_cbc();    } else if (m_type == TypeAes192 && m_mode == ModeCfb) {        return EVP_aes_192_cfb128();    } else if (m_type == TypeAes192 && m_mode == ModeEcb) {        return EVP_aes_192_ecb();    } else if (m_type == TypeAes192 && m_mode == ModeOfb) {        return EVP_aes_192_ofb();    } else if (m_type == TypeAes256 && m_mode == ModeCbc) {        return EVP_aes_256_cbc();    } else if (m_type == TypeAes256 && m_mode == ModeCfb) {        return EVP_aes_256_cfb128();    } else if (m_type == TypeAes256 && m_mode == ModeEcb) {        return EVP_aes_256_ecb();    } else if (m_type == TypeAes256 && m_mode == ModeOfb) {        return EVP_aes_256_ofb();    }    return 0;}
开发者ID:dushibaiyu,项目名称:QSocket5Tunnel,代码行数:30,


示例3: ossl_aes_cbc_init

static intossl_aes_cbc_init(PX_Cipher *c, const uint8 *key, unsigned klen, const uint8 *iv){	ossldata   *od = c->ptr;	int			err;	err = ossl_aes_init(c, key, klen, iv);	if (err)		return err;	switch (od->klen)	{		case 128 / 8:			od->evp_ciph = EVP_aes_128_cbc();			break;		case 192 / 8:			od->evp_ciph = EVP_aes_192_cbc();			break;		case 256 / 8:			od->evp_ciph = EVP_aes_256_cbc();			break;		default:			/* shouldn't happen */			err = PXE_CIPHER_INIT;			break;	}	return err;}
开发者ID:cconvey,项目名称:postgres,代码行数:29,


示例4: get_cipher_type

const EVP_CIPHER* get_cipher_type(const enum cipher cipher, const enum cipher_mode mode) {    switch (mode) {        case MODE_ECB:            switch (cipher) {                case CIPHER_DES:                    return EVP_des_ecb();                case CIPHER_AES_128:                    return EVP_aes_128_ecb();                case CIPHER_AES_192:                    return EVP_aes_192_ecb();                case CIPHER_AES_256:                    return EVP_aes_256_ecb();            }        case MODE_CBC:            switch (cipher) {                case CIPHER_DES:                    return EVP_des_cbc();                case CIPHER_AES_128:                    return EVP_aes_128_cbc();                case CIPHER_AES_192:                    return EVP_aes_192_cbc();                case CIPHER_AES_256:                    return EVP_aes_256_cbc();            }        case MODE_OFB:            switch (cipher) {                case CIPHER_DES:                    return EVP_des_ofb();                case CIPHER_AES_128:                    return EVP_aes_128_ofb();                case CIPHER_AES_192:                    return EVP_aes_192_ofb();                case CIPHER_AES_256:                    return EVP_aes_256_ofb();            }        case MODE_CFB:            switch (cipher) {                case CIPHER_DES:                    return EVP_des_cfb();                case CIPHER_AES_128:                    return EVP_aes_128_cfb();                case CIPHER_AES_192:                    return EVP_aes_192_cfb();                case CIPHER_AES_256:                    return EVP_aes_256_cfb();            }    }    abort();}
开发者ID:acrespo,项目名称:cripto-2013-1c,代码行数:58,


示例5: encrypt_then_mac

/**  * @brief Performs basic Encrypt-then-MAC style Authenticated Encryption. * * @param[in] ekey          a buffer holding the ENC key * @param[in] ekey_len      len of ekey buffer * @param[in] mkey          a buffer holding the MAC key * @param[in] mkey_len      len of mkey buffer * @param[in] input         the plaintext message * @param[in] input_len     len of message buffer * @param[in,out] ctxt      an allocated buffer, will hold the ciphertext * @param[in,out] ctxt_len  length of buffer, will hold length of ciphertext * @param[in,out] mac       an allocated buffer, will hold the MAC * @param[in,out] mac_len   length of buffer, will hold length of MAC * @param[in,out] iv        a randomly chosen iv (optional) * @param[in] iv_len        length of buffer for iv (optional) * @return 0 on success, non-zero on error **/int encrypt_then_mac(const unsigned char *ekey, size_t ekey_len,                      const unsigned char *mkey, size_t mkey_len,                     const unsigned char *input, size_t input_len,                     unsigned char *ctxt, size_t *ctxt_len,                     unsigned char *mac, size_t *mac_len,                     unsigned char *iv, size_t iv_len){    EVP_CIPHER_CTX *ctx;    ctx = EVP_CIPHER_CTX_new();    EVP_CIPHER *cipher = NULL;    int len;        if (!ekey || !ekey_len || !mkey || !mkey_len ||         !input_len || !ctxt || !ctxt_len || !mac || !mac_len)        return -1;        OpenSSL_add_all_algorithms();        EVP_CIPHER_CTX_init(ctx);    switch(ekey_len){        case 16:            cipher = (EVP_CIPHER *)EVP_aes_128_cbc();            break;        case 24:            cipher = (EVP_CIPHER *)EVP_aes_192_cbc();            break;        case 32:            cipher = (EVP_CIPHER *)EVP_aes_256_cbc();            break;        default:            return -1;    }    if (iv && iv_len) {        if (!RAND_bytes(iv, iv_len)) goto cleanup;    }    if (!EVP_EncryptInit(ctx, cipher, ekey, iv)) goto cleanup;        *ctxt_len = 0;    if (!EVP_EncryptUpdate(ctx, ctxt, (int *) ctxt_len, input, input_len))        goto cleanup;    EVP_EncryptFinal(ctx, ctxt + *ctxt_len, &len);    *ctxt_len += len;        // Do the HMAC-SHA1    *mac_len = 0;    if (!HMAC(EVP_sha1(), mkey, mkey_len, ctxt, *ctxt_len,                          mac, (unsigned int *) mac_len))        goto cleanup;    EVP_CIPHER_CTX_cleanup(ctx);    return 0;    cleanup:    if (ctxt_len) *ctxt_len = 0;    if (mac_len) *mac_len = 0;    return 1;}
开发者ID:gondree,项目名称:libpdp,代码行数:75,


示例6: verify_then_decrypt

/**  * @brief Performs basic Encrypt-then-MAC style Authenticated Encryption. * * @param[in] ekey            a buffer holding the ENC key * @param[in] ekey_len        len of ekey buffer * @param[in] mkey            a buffer holding the MAC key * @param[in] mkey_len        len of mkey buffer * @param[in] ctxt            a buffer holding the ciphertext * @param[in] ctxt_len        length of ciphertext * @param[in] mac             a buffer holding the MAC * @param[in] mac_len         length of MAC * @param[in] iv              an iv (optional) * @param[in] iv_len          length of iv (optional) * @param[out] output         an allocated buffer, will hold the plaintext * @param[in,out] output_len  length of buffer, will hold length of plaintext * @return 0 on success, non-zero on error **/int verify_then_decrypt(const unsigned char *ekey, size_t ekey_len,                         const unsigned char *mkey, size_t mkey_len,                        const unsigned char *ctxt, size_t ctxt_len,                        const unsigned char *mac, size_t mac_len,                        const unsigned char *iv, size_t iv_len,                        unsigned char *output, size_t *output_len){    EVP_CIPHER_CTX *ctx;    ctx = EVP_CIPHER_CTX_new();    EVP_CIPHER *cipher = NULL;    unsigned char auth[EVP_MAX_MD_SIZE];    size_t auth_len = EVP_MAX_MD_SIZE;    int len;        if (!ekey || !ekey_len || !mkey || !mkey_len ||         !ctxt || !ctxt_len || !mac || !mac_len || !output || !output_len)        return -1;        OpenSSL_add_all_algorithms();    memset(auth, 0, auth_len);    // Verify the HMAC-SHA1    if (!HMAC(EVP_sha1(), mkey, mkey_len, ctxt, ctxt_len,               auth, (unsigned int *) &auth_len))        goto cleanup;    if (auth_len != mac_len) goto cleanup;    if (memcmp(mac, auth, mac_len) != 0) goto cleanup;    EVP_CIPHER_CTX_init(ctx);    switch(ekey_len){        case 16:            cipher = (EVP_CIPHER *)EVP_aes_128_cbc();            break;        case 24:            cipher = (EVP_CIPHER *)EVP_aes_192_cbc();            break;        case 32:            cipher = (EVP_CIPHER *)EVP_aes_256_cbc();            break;        default:            return -1;    }    if (*output_len < ctxt_len) goto cleanup;    *output_len = 0;    if (!EVP_DecryptInit(ctx, cipher, ekey, iv)) goto cleanup;    if (!EVP_DecryptUpdate(ctx, output, (int *) output_len,                            ctxt, ctxt_len)) goto cleanup;    EVP_DecryptFinal(ctx, output + *output_len, &len);    *output_len += len;        EVP_CIPHER_CTX_cleanup(ctx);    return 0;    cleanup:    *output_len = 0;    return 1;}
开发者ID:gondree,项目名称:libpdp,代码行数:75,


示例7: RsaFree

/**  Retrieve the RSA Private Key from the password-protected PEM key data.  @param[in]  PemData      Pointer to the PEM-encoded key data to be retrieved.  @param[in]  PemSize      Size of the PEM key data in bytes.  @param[in]  Password     NULL-terminated passphrase used for encrypted PEM key data.  @param[out] RsaContext   Pointer to new-generated RSA context which contain the retrieved                           RSA private key component. Use RsaFree() function to free the                           resource.  If PemData is NULL, then return FALSE.  If RsaContext is NULL, then return FALSE.  @retval  TRUE   RSA Private Key was retrieved successfully.  @retval  FALSE  Invalid PEM key data or incorrect password.**/BOOLEANEFIAPIRsaGetPrivateKeyFromPem (  IN   CONST UINT8  *PemData,  IN   UINTN        PemSize,  IN   CONST CHAR8  *Password,  OUT  VOID         **RsaContext  ){  BOOLEAN  Status;  BIO      *PemBio;  //  // Check input parameters.  //  if (PemData == NULL || RsaContext == NULL || PemSize > INT_MAX) {    return FALSE;  }  Status = FALSE;  PemBio = NULL;  //  // Add possible block-cipher descriptor for PEM data decryption.  // NOTE: Only support most popular ciphers (3DES, AES) for the encrypted PEM.  //  EVP_add_cipher (EVP_des_ede3_cbc());  EVP_add_cipher (EVP_aes_128_cbc());  EVP_add_cipher (EVP_aes_192_cbc());  EVP_add_cipher (EVP_aes_256_cbc());  //  // Read encrypted PEM Data.  //  PemBio = BIO_new (BIO_s_mem ());  BIO_write (PemBio, PemData, (int)PemSize);  if (PemBio == NULL) {    goto _Exit;  }  //  // Retrieve RSA Private Key from encrypted PEM data.  //  *RsaContext = PEM_read_bio_RSAPrivateKey (PemBio, NULL, (pem_password_cb *)&PasswordCallback, (void *)Password);  if (*RsaContext != NULL) {    Status = TRUE;  }_Exit:  //  // Release Resources.  //  BIO_free (PemBio);  return Status;}
开发者ID:AshleyDeSimone,项目名称:edk2,代码行数:73,


示例8: SSL_library_init

intSSL_library_init(void){#ifndef OPENSSL_NO_DES	EVP_add_cipher(EVP_des_cbc());	EVP_add_cipher(EVP_des_ede3_cbc());#endif#ifndef OPENSSL_NO_IDEA	EVP_add_cipher(EVP_idea_cbc());#endif#ifndef OPENSSL_NO_RC4	EVP_add_cipher(EVP_rc4());#if !defined(OPENSSL_NO_MD5) && (defined(__x86_64) || defined(__x86_64__))	EVP_add_cipher(EVP_rc4_hmac_md5());#endif#endif  #ifndef OPENSSL_NO_RC2	EVP_add_cipher(EVP_rc2_cbc());	/* Not actually used for SSL/TLS but this makes PKCS#12 work	 * if an application only calls SSL_library_init().	 */	EVP_add_cipher(EVP_rc2_40_cbc());#endif	EVP_add_cipher(EVP_aes_128_cbc());	EVP_add_cipher(EVP_aes_192_cbc());	EVP_add_cipher(EVP_aes_256_cbc());	EVP_add_cipher(EVP_aes_128_gcm());	EVP_add_cipher(EVP_aes_256_gcm());	EVP_add_cipher(EVP_aes_128_cbc_hmac_sha1());	EVP_add_cipher(EVP_aes_256_cbc_hmac_sha1());#ifndef OPENSSL_NO_CAMELLIA	EVP_add_cipher(EVP_camellia_128_cbc());	EVP_add_cipher(EVP_camellia_256_cbc());#endif	EVP_add_digest(EVP_md5());	EVP_add_digest_alias(SN_md5, "ssl2-md5");	EVP_add_digest_alias(SN_md5, "ssl3-md5");	EVP_add_digest(EVP_sha1()); /* RSA with sha1 */	EVP_add_digest_alias(SN_sha1, "ssl3-sha1");	EVP_add_digest_alias(SN_sha1WithRSAEncryption, SN_sha1WithRSA);	EVP_add_digest(EVP_sha224());	EVP_add_digest(EVP_sha256());	EVP_add_digest(EVP_sha384());	EVP_add_digest(EVP_sha512());	EVP_add_digest(EVP_dss1()); /* DSA with sha1 */	EVP_add_digest_alias(SN_dsaWithSHA1, SN_dsaWithSHA1_2);	EVP_add_digest_alias(SN_dsaWithSHA1, "DSS1");	EVP_add_digest_alias(SN_dsaWithSHA1, "dss1");	EVP_add_digest(EVP_ecdsa());	/* initialize cipher/digest methods table */	ssl_load_ciphers();	return (1);}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:55,


示例9: _wi_cipher_cipher

static const EVP_CIPHER * _wi_cipher_cipher(wi_cipher_t *cipher) {	switch(cipher->type) {		case WI_CIPHER_AES128:		return EVP_aes_128_cbc();		case WI_CIPHER_AES192:		return EVP_aes_192_cbc();		case WI_CIPHER_AES256:		return EVP_aes_256_cbc();		case WI_CIPHER_BF128:		return EVP_bf_cbc();		case WI_CIPHER_3DES192:		return EVP_des_ede3_cbc();	}		return NULL;}
开发者ID:ProfDrLuigi,项目名称:zanka,代码行数:11,


示例10: decrypt_and_verify_secrets

int decrypt_and_verify_secrets(CPOR_key *key, unsigned char *input, size_t input_len, unsigned char *plaintext, size_t *plaintext_len, unsigned char *authenticator, size_t authenticator_len) {    EVP_CIPHER_CTX ctx;    EVP_CIPHER *cipher = NULL;    unsigned char mac[EVP_MAX_MD_SIZE];    size_t mac_size = EVP_MAX_MD_SIZE;    int len;    if(!key || !key->k_enc || !key->k_mac || !input || !input_len || !plaintext || !plaintext_len || !authenticator || !authenticator_len) return 0;    OpenSSL_add_all_algorithms();    memset(mac, 0, mac_size);    /* Verify the HMAC-SHA1 */    if(!HMAC(EVP_sha1(), key->k_mac, key->k_mac_size, input, input_len, mac, (unsigned int *)&mac_size)) goto cleanup;    if(authenticator_len != mac_size) goto cleanup;    if(memcmp(mac, authenticator, mac_size) != 0) goto cleanup;    EVP_CIPHER_CTX_init(&ctx);    switch(key->k_enc_size) {    case 16:        cipher = (EVP_CIPHER *)EVP_aes_128_cbc();        break;    case 24:        cipher = (EVP_CIPHER *)EVP_aes_192_cbc();        break;    case 32:        cipher = (EVP_CIPHER *)EVP_aes_256_cbc();        break;    default:        return 0;    }    if(!EVP_DecryptInit(&ctx, cipher, key->k_enc, NULL)) goto cleanup;    *plaintext_len = 0;    if(!EVP_DecryptUpdate(&ctx, plaintext, (int *)plaintext_len, input, input_len)) goto cleanup;    EVP_DecryptFinal(&ctx, plaintext + *plaintext_len, &len);    *plaintext_len += len;    EVP_CIPHER_CTX_cleanup(&ctx);    return 1;cleanup:    *plaintext_len = 0;    return 0;}
开发者ID:nypgit,项目名称:compact-proofs-of-retrievability,代码行数:52,


示例11: strdup

void *encfs_common_get_salt(char *ciphertext){	char *ctcopy = strdup(ciphertext);	char *keeptr = ctcopy;	int i;	char *p;	static encfs_common_custom_salt cs;	ctcopy += 7;	p = strtokm(ctcopy, "*");	cs.keySize = atoi(p);	switch(cs.keySize)	{		case 128:			cs.blockCipher = EVP_aes_128_cbc();			cs.streamCipher = EVP_aes_128_cfb();			break;		case 192:			cs.blockCipher = EVP_aes_192_cbc();			cs.streamCipher = EVP_aes_192_cfb();			break;		case 256:		default:			cs.blockCipher = EVP_aes_256_cbc();			cs.streamCipher = EVP_aes_256_cfb();			break;	}	cs.keySize = cs.keySize / 8;	p = strtokm(NULL, "*");	cs.iterations = atoi(p);	p = strtokm(NULL, "*");	cs.cipher = atoi(p);	p = strtokm(NULL, "*");	cs.saltLen = atoi(p);	p = strtokm(NULL, "*");	for (i = 0; i < cs.saltLen; i++)		cs.salt[i] =			atoi16[ARCH_INDEX(p[i * 2])] * 16 +			atoi16[ARCH_INDEX(p[i * 2 + 1])];	p = strtokm(NULL, "*");	cs.dataLen = atoi(p);	p = strtokm(NULL, "*");	for (i = 0; i < cs.dataLen; i++)		cs.data[i] =			atoi16[ARCH_INDEX(p[i * 2])] * 16 +			atoi16[ARCH_INDEX(p[i * 2 + 1])];	cs.ivLength = EVP_CIPHER_iv_length( cs.blockCipher );	MEM_FREE(keeptr);	return (void *) &cs;}
开发者ID:Allen-smith,项目名称:ctf-tools,代码行数:51,


示例12: encrypt_and_authentucate_secrets

int encrypt_and_authentucate_secrets(CPOR_key *key, unsigned char *input, size_t input_len, unsigned char *ciphertext, size_t *ciphertext_len, unsigned char *authenticator, size_t *authenticator_len) {    EVP_CIPHER_CTX ctx;    EVP_CIPHER *cipher = NULL;    int len;    if(!key || !key->k_enc || !key->k_mac || !input || !input_len || !ciphertext || !ciphertext_len || !authenticator || !authenticator_len) return 0;    OpenSSL_add_all_algorithms();    EVP_CIPHER_CTX_init(&ctx);    switch(key->k_enc_size) {    case 16:        cipher = (EVP_CIPHER *)EVP_aes_128_cbc();        break;    case 24:        cipher = (EVP_CIPHER *)EVP_aes_192_cbc();        break;    case 32:        cipher = (EVP_CIPHER *)EVP_aes_256_cbc();        break;    default:        return 0;    }    //TODO: Fix the NULL IV    if(!EVP_EncryptInit(&ctx, cipher, key->k_enc, NULL)) goto cleanup;    *ciphertext_len = 0;    if(!EVP_EncryptUpdate(&ctx, ciphertext, (int *)ciphertext_len, input, input_len)) goto cleanup;    EVP_EncryptFinal(&ctx, ciphertext + *ciphertext_len, &len);    *ciphertext_len += len;    *authenticator_len = 0;    /* Do the HMAC-SHA1 */    if(!HMAC(EVP_sha1(), key->k_mac, key->k_mac_size, ciphertext, *ciphertext_len,             authenticator, (unsigned int *)authenticator_len)) goto cleanup;    EVP_CIPHER_CTX_cleanup(&ctx);    return 1;cleanup:    *ciphertext_len = 0;    *authenticator_len = 0;    return 0;}
开发者ID:nypgit,项目名称:compact-proofs-of-retrievability,代码行数:50,


示例13: switch

static const EVP_CIPHER *getAesCipher(size32_t keyLen){    switch (keyLen)    {    case 128/8:        return EVP_aes_128_cbc();    case 192/8:        return EVP_aes_192_cbc();    case 256/8:        return EVP_aes_256_cbc();    default:        throw makeStringException(0, "Invalid AES key size, must be 128, 192 or 256 bit");    }}
开发者ID:AttilaVamos,项目名称:HPCC-Platform,代码行数:14,


示例14: FIPS_cmac_aes192_test

/* CMAC-AES192: generate hash of known digest value and compare to known   precomputed correct hash*/static int FIPS_cmac_aes192_test(){    unsigned char key[] = { 0x8e,0x73,0xb0,0xf7, 0xda,0x0e,0x64,0x52,                            0xc8,0x10,0xf3,0x2b, 0x80,0x90,0x79,0xe5,                            0x62,0xf8,0xea,0xd2, 0x52,0x2c,0x6b,0x7b,                          };    unsigned char data[] = "Sample text";    unsigned char kaval[] =    {   0xd6,0x99,0x19,0x25, 0xe5,0x1d,0x95,0x48,        0xb1,0x4a,0x0b,0xf2, 0xc6,0x3c,0x47,0x1f,    };    unsigned char *out = NULL;    size_t outlen;    CMAC_CTX *ctx = CMAC_CTX_new();    int r = 0;    ERR_clear_error();    if (!ctx)        goto end;    if (!CMAC_Init(ctx,key,sizeof(key),EVP_aes_192_cbc(),NULL))        goto end;    if (!CMAC_Update(ctx,data,sizeof(data)-1))        goto end;    /* This should return 1.  If not, there's a programming error... */    if (!CMAC_Final(ctx, out, &outlen))        goto end;    out = OPENSSL_malloc(outlen);    if (!CMAC_Final(ctx, out, &outlen))        goto end;#if 0    {        char *hexout = OPENSSL_malloc(outlen * 2 + 1);        bin2hex(out, outlen, hexout);        printf("CMAC-AES192: res = %s/n", hexout);        OPENSSL_free(hexout);    }    r = 1;#else    if (!memcmp(out,kaval,outlen))        r = 1;#endifend:    CMAC_CTX_free(ctx);    if (out)        OPENSSL_free(out);    return r;}
开发者ID:leloulight,项目名称:eme,代码行数:52,


示例15: aes_init

intaes_init (crypt_data_t* crypt_data, crypt_init_t crypt_init){    const EVP_CIPHER* cipher = 0;    switch (crypt_data->keysize) {    case 16:        cipher = EVP_aes_128_cbc ();        break;    case 24:        cipher = EVP_aes_192_cbc ();        break;    case 32:        cipher = EVP_aes_256_cbc ();        break;    default:        fprintf (stderr, "Invalid key size./n");        return -1;    }    EVP_CIPHER_CTX_init (&crypt_data->ctx);    if (!crypt_init (&crypt_data->ctx,                     cipher,                     NULL,                     crypt_data->keybuf,                     crypt_data->ivbuf)) {        fprintf (stderr, "OpenSSL initialization failed./n");        return 1;    }    if (verbose) {        fprintf (stderr,                 "EVP Initialized/n  Algorithm: %s/n",                 EVP_CIPHER_name (EVP_CIPHER_CTX_cipher (&crypt_data->ctx)));        fprintf (stderr, "  IV:  ");        pp_buf (stderr, crypt_data->ivbuf, crypt_data->ivsize, 16, 2);        fprintf (stderr, "  Key: ");        pp_buf (stderr, crypt_data->keybuf, crypt_data->keysize, 16, 2);    }    crypt_data->buf_size = INBUFSIZE;    crypt_data->out_buf =        (char*)malloc (crypt_data->buf_size +                       EVP_CIPHER_CTX_block_size (&crypt_data->ctx));    crypt_data->in_buf = (char*)malloc (crypt_data->buf_size);    if (!crypt_data->out_buf || !crypt_data->in_buf) {        fprintf (stderr, "Unable to allocate memory./n");        return 1;    }    return 0;}
开发者ID:flihp,项目名称:aes-pipe,代码行数:49,


示例16: Cipher

	explicit Cipher(Name name = N_AES128_CBC)		: cipher_(0)	{		EVP_CIPHER_CTX_init(&ctx_);		switch (name) {		case N_AES128_CBC: cipher_ = EVP_aes_128_cbc(); break;		case N_AES192_CBC: cipher_ = EVP_aes_192_cbc(); break;		case N_AES256_CBC: cipher_ = EVP_aes_256_cbc(); break;		case N_AES128_ECB: cipher_ = EVP_aes_128_ecb(); break;		case N_AES192_ECB: cipher_ = EVP_aes_192_ecb(); break;		case N_AES256_ECB: cipher_ = EVP_aes_256_ecb(); break;		default:			throw cybozu::Exception("crypto:Cipher:Cipher:name") << (int)name;		}	}
开发者ID:pombredanne,项目名称:cybozulib,代码行数:15,


示例17: evp_cipher_init

static void evp_cipher_init(struct ssh_cipher_struct *cipher) {    if (cipher->ctx == NULL) {        cipher->ctx = EVP_CIPHER_CTX_new();    }    switch(cipher->ciphertype){    case SSH_AES128_CBC:        cipher->cipher = EVP_aes_128_cbc();        break;    case SSH_AES192_CBC:        cipher->cipher = EVP_aes_192_cbc();        break;    case SSH_AES256_CBC:        cipher->cipher = EVP_aes_256_cbc();        break;#ifdef HAVE_OPENSSL_EVP_AES_CTR    case SSH_AES128_CTR:        cipher->cipher = EVP_aes_128_ctr();        break;    case SSH_AES192_CTR:        cipher->cipher = EVP_aes_192_ctr();        break;    case SSH_AES256_CTR:        cipher->cipher = EVP_aes_256_ctr();        break;#else    case SSH_AES128_CTR:    case SSH_AES192_CTR:    case SSH_AES256_CTR:        SSH_LOG(SSH_LOG_WARNING, "This cipher is not available in evp_cipher_init");        break;#endif    case SSH_3DES_CBC:        cipher->cipher = EVP_des_ede3_cbc();        break;    case SSH_BLOWFISH_CBC:        cipher->cipher = EVP_bf_cbc();        break;        /* ciphers not using EVP */    case SSH_3DES_CBC_SSH1:    case SSH_DES_CBC_SSH1:        SSH_LOG(SSH_LOG_WARNING, "This cipher should not use evp_cipher_init");        break;    case SSH_NO_CIPHER:        SSH_LOG(SSH_LOG_WARNING, "No valid ciphertype found");        break;    }}
开发者ID:codinn,项目名称:libssh,代码行数:48,


示例18: _wi_cipher_set_type

static wi_boolean_t _wi_cipher_set_type(wi_cipher_t *cipher, wi_cipher_type_t type) {	cipher->type = type;	#ifdef WI_CIPHER_OPENSSL	switch(cipher->type) {		case WI_CIPHER_AES128:			cipher->cipher = EVP_aes_128_cbc();			return true;					case WI_CIPHER_AES192:			cipher->cipher = EVP_aes_192_cbc();			return true;					case WI_CIPHER_AES256:			cipher->cipher = EVP_aes_256_cbc();			return true;					case WI_CIPHER_BF128:			cipher->cipher = EVP_bf_cbc();			return true;					case WI_CIPHER_3DES192:			cipher->cipher = EVP_des_ede3_cbc();			return true;					default:			return false;	}#endif			#ifdef WI_CIPHER_COMMONCRYPTO	switch(cipher->type) {		case WI_CIPHER_AES128:			cipher->algorithm = kCCAlgorithmAES128;			return true;				case WI_CIPHER_3DES192:			cipher->algorithm = kCCAlgorithm3DES;			return true;				default:			return false;	}#endif}
开发者ID:ProfDrLuigi,项目名称:zanka,代码行数:45,


示例19: ERROR_MSG

const EVP_CIPHER* OSSLAES::getCipher() const{	if (currentKey == NULL) return NULL;	// Check currentKey bit length; AES only supports 128, 192 or 256 bit keys	if ((currentKey->getBitLen() != 128) && 	    (currentKey->getBitLen() != 192) &&            (currentKey->getBitLen() != 256))	{		ERROR_MSG("Invalid AES currentKey length (%d bits)", currentKey->getBitLen());		return NULL;	}	// Determine the cipher mode	if (!currentCipherMode.compare("cbc"))	{		switch(currentKey->getBitLen())		{			case 128:				return EVP_aes_128_cbc();			case 192:				return EVP_aes_192_cbc();			case 256:				return EVP_aes_256_cbc();		};	}	else if (!currentCipherMode.compare("ecb"))	{		switch(currentKey->getBitLen())		{			case 128:				return EVP_aes_128_ecb();			case 192:				return EVP_aes_192_ecb();			case 256:				return EVP_aes_256_ecb();		};	}	ERROR_MSG("Invalid AES cipher mode %s", currentCipherMode.c_str());	return NULL;}
开发者ID:rene-post,项目名称:SoftHSMv2,代码行数:44,


示例20: SSLInitImpl

void SSLInitImpl(){    if(0 == ssl_init_counter++)     {        log_info("OpenSSL library initialization");        SSL_library_init();        SSL_load_error_strings();        ERR_load_crypto_strings();        int numLocks = CRYPTO_num_locks();        sslmtx = new Pt::System::Mutex[numLocks];	      //CRYPTO_set_id_callback((unsigned long (*)())pthreads_thread_id);	      CRYPTO_set_locking_callback(pt_locking_callback_impl);        //OpenSSL_add_all_algorithms();        EVP_add_cipher(EVP_des_ede3_cfb());        EVP_add_cipher(EVP_des_ede3_cfb1());        EVP_add_cipher(EVP_des_ede3_cfb8());        EVP_add_cipher(EVP_des_ede3_ofb());        EVP_add_cipher(EVP_aes_128_ecb());        EVP_add_cipher(EVP_aes_128_cbc());        EVP_add_cipher(EVP_aes_128_cfb());        EVP_add_cipher(EVP_aes_128_cfb1());        EVP_add_cipher(EVP_aes_128_cfb8());        EVP_add_cipher(EVP_aes_128_ofb());        EVP_add_cipher(EVP_aes_192_ecb());        EVP_add_cipher(EVP_aes_192_cbc());        EVP_add_cipher(EVP_aes_192_cfb());        EVP_add_cipher(EVP_aes_192_cfb1());        EVP_add_cipher(EVP_aes_192_cfb8());        EVP_add_cipher(EVP_aes_192_ofb());        EVP_add_cipher(EVP_aes_256_ecb());        EVP_add_cipher(EVP_aes_256_cbc());        EVP_add_cipher(EVP_aes_256_cfb());        EVP_add_cipher(EVP_aes_256_cfb1());        EVP_add_cipher(EVP_aes_256_cfb8());        EVP_add_cipher(EVP_aes_256_ofb());    }}
开发者ID:3Nigma,项目名称:frayon,代码行数:42,


示例21: switch

const EVP_CIPHER* AesCbcCipher::getCipher() const{    const EVP_CIPHER* cipher = NULL;    switch (keyLength_)    {    case KL128:        cipher = EVP_aes_128_cbc();        break;    case KL192:        cipher = EVP_aes_192_cbc();        break;    case KL256:        cipher = EVP_aes_256_cbc();        break;    default:        assert(false);        break;    }    return cipher;}
开发者ID:javascript-forks,项目名称:Netflix.NfWebCrypto,代码行数:20,


示例22: switch

const EVP_CIPHER *EVP_get_cipherbynid(int nid) {  switch (nid) {    case NID_rc2_cbc:      return EVP_rc2_cbc();    case NID_rc2_40_cbc:      return EVP_rc2_40_cbc();    case NID_des_ede3_cbc:      return EVP_des_ede3_cbc();    case NID_des_ede_cbc:      return EVP_des_cbc();    case NID_aes_128_cbc:      return EVP_aes_128_cbc();    case NID_aes_192_cbc:      return EVP_aes_192_cbc();    case NID_aes_256_cbc:      return EVP_aes_256_cbc();    default:      return NULL;  }}
开发者ID:AadityaDev,项目名称:AadityaDev.github.io,代码行数:20,


示例23: MAIN

int MAIN(int argc, char **argv)	{#ifndef OPENSSL_NO_ENGINE	ENGINE *e = NULL;#endif	DSA *dsa=NULL;	int ret=1;	char *outfile=NULL;	char *inrand=NULL,*dsaparams=NULL;	char *passargout = NULL, *passout = NULL;	BIO *out=NULL,*in=NULL;	const EVP_CIPHER *enc=NULL;#ifndef OPENSSL_NO_ENGINE	char *engine=NULL;#endif	apps_startup();	if (bio_err == NULL)		if ((bio_err=BIO_new(BIO_s_file())) != NULL)			BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);	if (!load_config(bio_err, NULL))		goto end;	argv++;	argc--;	for (;;)		{		if (argc <= 0) break;		if (strcmp(*argv,"-out") == 0)			{			if (--argc < 1) goto bad;			outfile= *(++argv);			}		else if (strcmp(*argv,"-passout") == 0)			{			if (--argc < 1) goto bad;			passargout= *(++argv);			}#ifndef OPENSSL_NO_ENGINE		else if (strcmp(*argv,"-engine") == 0)			{			if (--argc < 1) goto bad;			engine= *(++argv);			}#endif		else if (strcmp(*argv,"-rand") == 0)			{			if (--argc < 1) goto bad;			inrand= *(++argv);			}		else if (strcmp(*argv,"-") == 0)			goto bad;#ifndef OPENSSL_NO_DES		else if (strcmp(*argv,"-des") == 0)			enc=EVP_des_cbc();		else if (strcmp(*argv,"-des3") == 0)			enc=EVP_des_ede3_cbc();#endif#ifndef OPENSSL_NO_IDEA		else if (strcmp(*argv,"-idea") == 0)			enc=EVP_idea_cbc();#endif#ifndef OPENSSL_NO_SEED		else if (strcmp(*argv,"-seed") == 0)			enc=EVP_seed_cbc();#endif#ifndef OPENSSL_NO_AES		else if (strcmp(*argv,"-aes128") == 0)			enc=EVP_aes_128_cbc();		else if (strcmp(*argv,"-aes192") == 0)			enc=EVP_aes_192_cbc();		else if (strcmp(*argv,"-aes256") == 0)			enc=EVP_aes_256_cbc();#endif#ifndef OPENSSL_NO_CAMELLIA		else if (strcmp(*argv,"-camellia128") == 0)			enc=EVP_camellia_128_cbc();		else if (strcmp(*argv,"-camellia192") == 0)			enc=EVP_camellia_192_cbc();		else if (strcmp(*argv,"-camellia256") == 0)			enc=EVP_camellia_256_cbc();#endif		else if (**argv != '-' && dsaparams == NULL)			{			dsaparams = *argv;			}		else			goto bad;		argv++;		argc--;		}	if (dsaparams == NULL)		{bad:		BIO_printf(bio_err,"usage: gendsa [args] dsaparam-file/n");		BIO_printf(bio_err," -out file - output the key to 'file'/n");#ifndef OPENSSL_NO_DES//.........这里部分代码省略.........
开发者ID:LucidOne,项目名称:Rovio,代码行数:101,


示例24: MAIN

int MAIN(int argc, char **argv)	{	BN_GENCB cb;#ifndef OPENSSL_NO_ENGINE	ENGINE *e = NULL;#endif	int ret=1;	int i,num=DEFBITS;	long l;	const EVP_CIPHER *enc=NULL;	unsigned long f4=RSA_F4;	char *outfile=NULL;	char *passargout = NULL, *passout = NULL;#ifndef OPENSSL_NO_ENGINE	char *engine=NULL;#endif	char *inrand=NULL;	BIO *out=NULL;	BIGNUM *bn = BN_new();	RSA *rsa = NULL;	if(!bn) goto err;	apps_startup();	BN_GENCB_set(&cb, genrsa_cb, bio_err);	if (bio_err == NULL)		if ((bio_err=BIO_new(BIO_s_file())) != NULL)			BIO_set_fp(bio_err,OPENSSL_TYPE__FILE_STDERR,BIO_NOCLOSE|BIO_FP_TEXT);	if (!load_config(bio_err, NULL))		goto err;	if ((out=BIO_new(BIO_s_file())) == NULL)		{		BIO_printf(bio_err,"unable to create BIO for output/n");		goto err;		}	argv++;	argc--;	for (;;)		{		if (argc <= 0) break;		if (TINYCLR_SSL_STRCMP(*argv,"-out") == 0)			{			if (--argc < 1) goto bad;			outfile= *(++argv);			}		else if (TINYCLR_SSL_STRCMP(*argv,"-3") == 0)			f4=3;		else if (TINYCLR_SSL_STRCMP(*argv,"-F4") == 0 || TINYCLR_SSL_STRCMP(*argv,"-f4") == 0)			f4=RSA_F4;#ifndef OPENSSL_NO_ENGINE		else if (TINYCLR_SSL_STRCMP(*argv,"-engine") == 0)			{			if (--argc < 1) goto bad;			engine= *(++argv);			}#endif		else if (TINYCLR_SSL_STRCMP(*argv,"-rand") == 0)			{			if (--argc < 1) goto bad;			inrand= *(++argv);			}#ifndef OPENSSL_NO_DES		else if (TINYCLR_SSL_STRCMP(*argv,"-des") == 0)			enc=EVP_des_cbc();		else if (TINYCLR_SSL_STRCMP(*argv,"-des3") == 0)			enc=EVP_des_ede3_cbc();#endif#ifndef OPENSSL_NO_IDEA		else if (TINYCLR_SSL_STRCMP(*argv,"-idea") == 0)			enc=EVP_idea_cbc();#endif#ifndef OPENSSL_NO_SEED		else if (TINYCLR_SSL_STRCMP(*argv,"-seed") == 0)			enc=EVP_seed_cbc();#endif#ifndef OPENSSL_NO_AES		else if (TINYCLR_SSL_STRCMP(*argv,"-aes128") == 0)			enc=EVP_aes_128_cbc();		else if (TINYCLR_SSL_STRCMP(*argv,"-aes192") == 0)			enc=EVP_aes_192_cbc();		else if (TINYCLR_SSL_STRCMP(*argv,"-aes256") == 0)			enc=EVP_aes_256_cbc();#endif#ifndef OPENSSL_NO_CAMELLIA		else if (TINYCLR_SSL_STRCMP(*argv,"-camellia128") == 0)			enc=EVP_camellia_128_cbc();		else if (TINYCLR_SSL_STRCMP(*argv,"-camellia192") == 0)			enc=EVP_camellia_192_cbc();		else if (TINYCLR_SSL_STRCMP(*argv,"-camellia256") == 0)			enc=EVP_camellia_256_cbc();#endif		else if (TINYCLR_SSL_STRCMP(*argv,"-passout") == 0)			{			if (--argc < 1) goto bad;			passargout= *(++argv);			}		else//.........这里部分代码省略.........
开发者ID:AustinWise,项目名称:Netduino-Micro-Framework,代码行数:101,


示例25: OpenSSL_add_all_ciphers

void OpenSSL_add_all_ciphers(void)	{#ifndef OPENSSL_NO_DES	EVP_add_cipher(EVP_des_cfb());	EVP_add_cipher(EVP_des_cfb1());	EVP_add_cipher(EVP_des_cfb8());	EVP_add_cipher(EVP_des_ede_cfb());	EVP_add_cipher(EVP_des_ede3_cfb());	EVP_add_cipher(EVP_des_ofb());	EVP_add_cipher(EVP_des_ede_ofb());	EVP_add_cipher(EVP_des_ede3_ofb());	EVP_add_cipher(EVP_desx_cbc());	EVP_add_cipher_alias(SN_desx_cbc,"DESX");	EVP_add_cipher_alias(SN_desx_cbc,"desx");	EVP_add_cipher(EVP_des_cbc());	EVP_add_cipher_alias(SN_des_cbc,"DES");	EVP_add_cipher_alias(SN_des_cbc,"des");	EVP_add_cipher(EVP_des_ede_cbc());	EVP_add_cipher(EVP_des_ede3_cbc());	EVP_add_cipher_alias(SN_des_ede3_cbc,"DES3");	EVP_add_cipher_alias(SN_des_ede3_cbc,"des3");	EVP_add_cipher(EVP_des_ecb());	EVP_add_cipher(EVP_des_ede());	EVP_add_cipher(EVP_des_ede3());#endif#ifndef OPENSSL_NO_RC4	EVP_add_cipher(EVP_rc4());	EVP_add_cipher(EVP_rc4_40());#endif#ifndef OPENSSL_NO_IDEA	EVP_add_cipher(EVP_idea_ecb());	EVP_add_cipher(EVP_idea_cfb());	EVP_add_cipher(EVP_idea_ofb());	EVP_add_cipher(EVP_idea_cbc());	EVP_add_cipher_alias(SN_idea_cbc,"IDEA");	EVP_add_cipher_alias(SN_idea_cbc,"idea");#endif#ifndef OPENSSL_NO_RC2	EVP_add_cipher(EVP_rc2_ecb());	EVP_add_cipher(EVP_rc2_cfb());	EVP_add_cipher(EVP_rc2_ofb());	EVP_add_cipher(EVP_rc2_cbc());	EVP_add_cipher(EVP_rc2_40_cbc());	EVP_add_cipher(EVP_rc2_64_cbc());	EVP_add_cipher_alias(SN_rc2_cbc,"RC2");	EVP_add_cipher_alias(SN_rc2_cbc,"rc2");#endif#ifndef OPENSSL_NO_BF	EVP_add_cipher(EVP_bf_ecb());	EVP_add_cipher(EVP_bf_cfb());	EVP_add_cipher(EVP_bf_ofb());	EVP_add_cipher(EVP_bf_cbc());	EVP_add_cipher_alias(SN_bf_cbc,"BF");	EVP_add_cipher_alias(SN_bf_cbc,"bf");	EVP_add_cipher_alias(SN_bf_cbc,"blowfish");#endif#ifndef OPENSSL_NO_CAST	EVP_add_cipher(EVP_cast5_ecb());	EVP_add_cipher(EVP_cast5_cfb());	EVP_add_cipher(EVP_cast5_ofb());	EVP_add_cipher(EVP_cast5_cbc());	EVP_add_cipher_alias(SN_cast5_cbc,"CAST");	EVP_add_cipher_alias(SN_cast5_cbc,"cast");	EVP_add_cipher_alias(SN_cast5_cbc,"CAST-cbc");	EVP_add_cipher_alias(SN_cast5_cbc,"cast-cbc");#endif#ifndef OPENSSL_NO_RC5	EVP_add_cipher(EVP_rc5_32_12_16_ecb());	EVP_add_cipher(EVP_rc5_32_12_16_cfb());	EVP_add_cipher(EVP_rc5_32_12_16_ofb());	EVP_add_cipher(EVP_rc5_32_12_16_cbc());	EVP_add_cipher_alias(SN_rc5_cbc,"rc5");	EVP_add_cipher_alias(SN_rc5_cbc,"RC5");#endif#ifndef OPENSSL_NO_AES	EVP_add_cipher(EVP_aes_128_ecb());	EVP_add_cipher(EVP_aes_128_cbc());	EVP_add_cipher(EVP_aes_128_cfb());	EVP_add_cipher(EVP_aes_128_cfb1());	EVP_add_cipher(EVP_aes_128_cfb8());	EVP_add_cipher(EVP_aes_128_ofb());#if 0	EVP_add_cipher(EVP_aes_128_ctr());#endif	EVP_add_cipher_alias(SN_aes_128_cbc,"AES128");	EVP_add_cipher_alias(SN_aes_128_cbc,"aes128");	EVP_add_cipher(EVP_aes_192_ecb());	EVP_add_cipher(EVP_aes_192_cbc());//.........这里部分代码省略.........
开发者ID:FelipeFernandes1988,项目名称:Alice-1121-Modem,代码行数:101,


示例26: MAIN

//.........这里部分代码省略.........            operation = SMIME_DIGEST_CREATE;        else if (!strcmp(*args, "-compress"))            operation = SMIME_COMPRESS;        else if (!strcmp(*args, "-uncompress"))            operation = SMIME_UNCOMPRESS;        else if (!strcmp(*args, "-EncryptedData_decrypt"))            operation = SMIME_ENCRYPTED_DECRYPT;        else if (!strcmp(*args, "-EncryptedData_encrypt"))            operation = SMIME_ENCRYPTED_ENCRYPT;# ifndef OPENSSL_NO_DES        else if (!strcmp(*args, "-des3"))            cipher = EVP_des_ede3_cbc();        else if (!strcmp(*args, "-des"))            cipher = EVP_des_cbc();        else if (!strcmp(*args, "-des3-wrap"))            wrap_cipher = EVP_des_ede3_wrap();# endif# ifndef OPENSSL_NO_SEED        else if (!strcmp(*args, "-seed"))            cipher = EVP_seed_cbc();# endif# ifndef OPENSSL_NO_RC2        else if (!strcmp(*args, "-rc2-40"))            cipher = EVP_rc2_40_cbc();        else if (!strcmp(*args, "-rc2-128"))            cipher = EVP_rc2_cbc();        else if (!strcmp(*args, "-rc2-64"))            cipher = EVP_rc2_64_cbc();# endif# ifndef OPENSSL_NO_AES        else if (!strcmp(*args, "-aes128"))            cipher = EVP_aes_128_cbc();        else if (!strcmp(*args, "-aes192"))            cipher = EVP_aes_192_cbc();        else if (!strcmp(*args, "-aes256"))            cipher = EVP_aes_256_cbc();        else if (!strcmp(*args, "-aes128-wrap"))            wrap_cipher = EVP_aes_128_wrap();        else if (!strcmp(*args, "-aes192-wrap"))            wrap_cipher = EVP_aes_192_wrap();        else if (!strcmp(*args, "-aes256-wrap"))            wrap_cipher = EVP_aes_256_wrap();# endif# ifndef OPENSSL_NO_CAMELLIA        else if (!strcmp(*args, "-camellia128"))            cipher = EVP_camellia_128_cbc();        else if (!strcmp(*args, "-camellia192"))            cipher = EVP_camellia_192_cbc();        else if (!strcmp(*args, "-camellia256"))            cipher = EVP_camellia_256_cbc();# endif        else if (!strcmp(*args, "-debug_decrypt"))            flags |= CMS_DEBUG_DECRYPT;        else if (!strcmp(*args, "-text"))            flags |= CMS_TEXT;        else if (!strcmp(*args, "-nointern"))            flags |= CMS_NOINTERN;        else if (!strcmp(*args, "-noverify")                 || !strcmp(*args, "-no_signer_cert_verify"))            flags |= CMS_NO_SIGNER_CERT_VERIFY;        else if (!strcmp(*args, "-nocerts"))            flags |= CMS_NOCERTS;        else if (!strcmp(*args, "-noattr"))            flags |= CMS_NOATTR;        else if (!strcmp(*args, "-nodetach"))            flags &= ~CMS_DETACHED;
开发者ID:davidlt,项目名称:openssl-fedora,代码行数:67,


示例27: EVP_CIPHER_CTX_init

void AESCryptoKey::TransformBlock(bool           encrypt,                                  const uint8_t *pbIn,                                  uint32_t       cbIn,                                  uint8_t       *pbOut,                                  uint32_t     & cbOut,                                  const uint8_t *pbIv,                                  uint32_t       cbIv){  if (pbIn == nullptr) {    throw exceptions::RMSCryptoNullPointerException("Null pointer pbIn exception");  }  if (pbOut == nullptr) {    throw exceptions::RMSCryptoNullPointerException("Null pointer pbOut exception");  }  if (((cbIv == 0) && (pbIv != nullptr)) || ((cbIv != 0) && (pbIv == nullptr))) {    pbIv = nullptr;    cbIv = 0;  }  int totalOut = static_cast<int>(cbOut);  EVP_CIPHER_CTX ctx;  EVP_CIPHER_CTX_init(&ctx);  const EVP_CIPHER *cipher = nullptr;  switch (m_algorithm) {  case api::CRYPTO_ALGORITHM_AES_ECB:    switch(m_key.size()) {    case 16:       cipher = EVP_aes_128_ecb();       break;    case 24:       cipher = EVP_aes_192_ecb();       break;    case 32:       cipher = EVP_aes_256_ecb();       break;    default:        throw exceptions::RMSCryptoInvalidArgumentException("Invalid key length");    }    break;  case api::CRYPTO_ALGORITHM_AES_CBC:  case api::CRYPTO_ALGORITHM_AES_CBC_PKCS7:      switch(m_key.size()) {      case 16:         cipher = EVP_aes_128_cbc();         break;      case 24:         cipher = EVP_aes_192_cbc();         break;      case 32:         cipher = EVP_aes_256_cbc();         break;      default:          throw exceptions::RMSCryptoInvalidArgumentException("Invalid key length");      }      break;    break;  default:    throw exceptions::RMSCryptoInvalidArgumentException("Unsupported algorithm");  }  // check lengths  if ((pbIv != nullptr) &&      (EVP_CIPHER_iv_length(cipher) != static_cast<int>(cbIv))) {    throw exceptions::RMSCryptoInvalidArgumentException(            "Invalid initial vector length");  }  if (EVP_CIPHER_key_length(cipher) != static_cast<int>(m_key.size())) {    throw exceptions::RMSCryptoInvalidArgumentException("Invalid key length");  }  EVP_CipherInit_ex(&ctx, cipher, NULL, m_key.data(), pbIv, encrypt ? 1 : 0);  if (m_algorithm == api::CRYPTO_ALGORITHM_AES_CBC_PKCS7) {    EVP_CIPHER_CTX_set_padding(&ctx, 1);  } else {    EVP_CIPHER_CTX_set_padding(&ctx, 0);  }  if (!EVP_CipherUpdate(&ctx, pbOut, &totalOut, pbIn, static_cast<int>(cbIn))) {    throw exceptions::RMSCryptoIOException(            exceptions::RMSCryptoException::UnknownError,            "Failed to transform data");  }  pbOut += totalOut;  // add padding if necessary  if (m_algorithm == api::CRYPTO_ALGORITHM_AES_CBC_PKCS7) {    int remain = cbOut - totalOut;    if (remain < EVP_CIPHER_block_size(cipher)) {      throw exceptions::RMSCryptoInsufficientBufferException(              "No enough buffer size");    }//.........这里部分代码省略.........
开发者ID:AzureAD,项目名称:rms-sdk-for-cpp,代码行数:101,


示例28: cipher_new

struct iked_cipher *cipher_new(uint8_t type, uint16_t id, uint16_t id_length){	struct iked_cipher	*encr;	const EVP_CIPHER	*cipher = NULL;	EVP_CIPHER_CTX		*ctx = NULL;	int			 length = 0, fixedkey = 0, ivlength = 0;	switch (type) {	case IKEV2_XFORMTYPE_ENCR:		switch (id) {		case IKEV2_XFORMENCR_3DES:			cipher = EVP_des_ede3_cbc();			length = EVP_CIPHER_block_size(cipher);			fixedkey = EVP_CIPHER_key_length(cipher);			ivlength = EVP_CIPHER_iv_length(cipher);			break;		case IKEV2_XFORMENCR_AES_CBC:			switch (id_length) {			case 128:				cipher = EVP_aes_128_cbc();				break;			case 192:				cipher = EVP_aes_192_cbc();				break;			case 256:				cipher = EVP_aes_256_cbc();				break;			default:				log_debug("%s: invalid key length %d"				    " for cipher %s", __func__, id_length,				    print_map(id, ikev2_xformencr_map));				break;			}			if (cipher == NULL)				break;			length = EVP_CIPHER_block_size(cipher);			ivlength = EVP_CIPHER_iv_length(cipher);			fixedkey = EVP_CIPHER_key_length(cipher);			break;		case IKEV2_XFORMENCR_DES_IV64:		case IKEV2_XFORMENCR_DES:		case IKEV2_XFORMENCR_RC5:		case IKEV2_XFORMENCR_IDEA:		case IKEV2_XFORMENCR_CAST:		case IKEV2_XFORMENCR_BLOWFISH:		case IKEV2_XFORMENCR_3IDEA:		case IKEV2_XFORMENCR_DES_IV32:		case IKEV2_XFORMENCR_NULL:		case IKEV2_XFORMENCR_AES_CTR:			/* FALLTHROUGH */		default:			log_debug("%s: cipher %s not supported", __func__,			    print_map(id, ikev2_xformencr_map));			cipher = NULL;			break;		}		break;	default:		log_debug("%s: cipher type %s not supported", __func__,		    print_map(id, ikev2_xformtype_map));		break;	}	if (cipher == NULL)		return (NULL);	if ((encr = calloc(1, sizeof(*encr))) == NULL) {		log_debug("%s: alloc cipher", __func__);		return (NULL);	}	encr->encr_id = id;	encr->encr_priv = cipher;	encr->encr_ctx = NULL;	encr->encr_length = length;	encr->encr_fixedkey = fixedkey;	encr->encr_ivlength = ivlength ? ivlength : length;	if ((ctx = calloc(1, sizeof(*ctx))) == NULL) {		log_debug("%s: alloc cipher ctx", __func__);		cipher_free(encr);		return (NULL);	}	EVP_CIPHER_CTX_init(ctx);	encr->encr_ctx = ctx;	return (encr);}
开发者ID:jymigeon,项目名称:openiked,代码行数:89,



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


C++ EVP_aes_256_cbc函数代码示例
C++ EVP_aes_128_ecb函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。