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

C++ EVP_CipherUpdate函数代码示例

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

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



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

示例1: XCBC_Init

int
XCBC_Init(XCBC_CTX *xctx,
	  const uint8_t const *k)
{
	int bl, outl;
	EVP_CIPHER_CTX *ctx;
	uint8_t k1[XCBC_MAX_BLOCK_LENGTH];

	ctx = xctx->ctx;

	EVP_CIPHER_CTX_init(ctx);
	OPENSSL_try(EVP_CipherInit_ex(ctx, EVP_aes_128_ecb(), NULL, k, NULL, 1),
		    "cipher init error", return0);
	bl = EVP_CIPHER_CTX_block_size((const EVP_CIPHER_CTX *)ctx);
	OPENSSL_try(EVP_CipherUpdate(ctx,       k1, &outl, ks1, bl),
		    "cipher update error (k1)", return0);
	OPENSSL_try(EVP_CipherUpdate(ctx, xctx->k2, &outl, ks2, bl),
		    "cipher update error (k2)", return0);
	OPENSSL_try(EVP_CipherUpdate(ctx, xctx->k3, &outl, ks3, bl),
		    "cipher update error (k3)", return0);

	OPENSSL_try(EVP_CipherInit_ex(ctx, NULL, NULL, k1, NULL, -1),
		    "cipher reset error", return0);
	memset(xctx->e, 0, bl);
	xctx->size = 0;

	return 1;

return0:
	return 0;
}
开发者ID:grivet,项目名称:XCBC,代码行数:31,代码来源:xcbc.c


示例2: encrypt_buf

void encrypt_buf(struct encryption_ctx *ctx, char *buf, int *len) {
    if (_method == EncryptionTable) {
        table_encrypt(buf, *len);
    } else {
        if (ctx->status == STATUS_EMPTY) {
            int iv_len = encryption_iv_len[_method];
            unsigned char iv[EVP_MAX_IV_LENGTH];
            memset(iv, 0, iv_len);
            RAND_bytes(iv, iv_len);
            init_cipher(ctx, iv, iv_len, 1);
            int out_len = *len + EVP_CIPHER_CTX_block_size(ctx->ctx);
            unsigned char *cipher_text = malloc(out_len);
            EVP_CipherUpdate(ctx->ctx, cipher_text, &out_len, buf, *len);
            memcpy(buf, iv, iv_len);
            memcpy(buf + iv_len, cipher_text, out_len);
            *len = iv_len + out_len;
            free(cipher_text);
        } else {
            int out_len = *len + EVP_CIPHER_CTX_block_size(ctx->ctx);
            unsigned char *cipher_text = malloc(out_len);
            EVP_CipherUpdate(ctx->ctx, cipher_text, &out_len, buf, *len);
            memcpy(buf, cipher_text, out_len);
            *len = out_len;
            free(cipher_text);
        }
    }
}
开发者ID:hynnet,项目名称:ShadowWeb,代码行数:27,代码来源:encrypt.c


示例3: ossl_cipher_update_long

static int
ossl_cipher_update_long(EVP_CIPHER_CTX *ctx, unsigned char *out, long *out_len_ptr,
			const unsigned char *in, long in_len)
{
    int out_part_len;
    long out_len = 0;
#define UPDATE_LENGTH_LIMIT INT_MAX

#if SIZEOF_LONG > UPDATE_LENGTH_LIMIT
    if (in_len > UPDATE_LENGTH_LIMIT) {
	const int in_part_len = (UPDATE_LENGTH_LIMIT / 2 + 1) & ~1;
	do {
	    if (!EVP_CipherUpdate(ctx, out ? (out + out_len) : 0,
				  &out_part_len, in, in_part_len))
		return 0;
	    out_len += out_part_len;
	    in += in_part_len;
	} while ((in_len -= in_part_len) > UPDATE_LENGTH_LIMIT);
    }
#endif
    if (!EVP_CipherUpdate(ctx, out ? (out + out_len) : 0,
			  &out_part_len, in, (int)in_len))
	return 0;
    if (out_len_ptr) *out_len_ptr = out_len += out_part_len;
    return 1;
}
开发者ID:hilben,项目名称:ruby_test,代码行数:26,代码来源:ossl_cipher.c


示例4: main

int main(int N, char ** S)
{
    unsigned char key[]= "helloworld" ;
    unsigned char iv[]= "12345678" ;
    char * destp ;
    int iuse, iuse2 ;

    EVP_CIPHER_CTX ctx;

    OpenSSL_add_all_ciphers() ;

    printf("test: (%s) len %zd.\n", test, strlen(test)) ;

    EVP_CIPHER_CTX_init(&ctx) ;

    // encode
    EVP_CipherInit_ex(&ctx, EVP_bf_cbc(), NULL, NULL, NULL, 1);
    EVP_CIPHER_CTX_set_key_length(&ctx, strlen(key));
    EVP_CipherInit_ex(&ctx, NULL, NULL, key, iv, -1);

    destp= buffer ;

    EVP_CipherUpdate(&ctx, destp, &iuse, test, strlen(test) +1) ;
    destp += iuse ;
    EVP_CipherFinal_ex(&ctx, destp, &iuse) ;
    destp += iuse ;
    iuse= ( destp - buffer ) ;

    EVP_CIPHER_CTX_cleanup(&ctx);

    // decode
    EVP_CipherInit_ex(&ctx, EVP_bf_cbc(), NULL, NULL, NULL, 0);
    EVP_CIPHER_CTX_set_key_length(&ctx, strlen(key));
    EVP_CipherInit_ex(&ctx, NULL, NULL, key, iv, -1);

    destp= buffer2 ;

    EVP_CipherUpdate(&ctx, destp, &iuse2, buffer, iuse ) ;
    destp += iuse2 ;
    EVP_CipherFinal_ex(&ctx, destp, &iuse2) ;
    destp += iuse2 ;
    iuse2= ( destp - buffer2 ) ;

    EVP_CIPHER_CTX_cleanup(&ctx);

    EVP_cleanup() ;

    encode_asc85(printbuf, sizeof(printbuf), test, strlen(test) +1) ;
    printf("SRC: %s\n", printbuf) ;
    encode_asc85(printbuf, sizeof(printbuf), buffer, iuse) ;
    printf("ENC: %s\n", printbuf) ;
    encode_asc85(printbuf, sizeof(printbuf), buffer2, iuse2) ;
    printf("DEC: %s\nout: %s\n", printbuf, buffer2) ;
}
开发者ID:GDXN,项目名称:test,代码行数:54,代码来源:testevp.c


示例5: XCBC_Final

int
XCBC_Final(XCBC_CTX *xctx,
	   uint8_t  *out)
{
	int bl, n, outl;

	bl = EVP_CIPHER_CTX_block_size(xctx->ctx);

	/* xctx->r = M[n] */
	if (xctx->size == bl) {
		for (n = 0; n < bl; n++)
			xctx->m[n] = xctx->r[n] ^ xctx->e[n] ^ xctx->k2[n];
	} else {
		for (n = xctx->size; n < bl; n++)
			xctx->r[n] = (n == xctx->size) ? 0x80 : 0x00;
		for (n = 0; n < bl; n++) {
			xctx->m[n] = xctx->r[n] ^ xctx->e[n] ^ xctx->k3[n];
		}
	}
	OPENSSL_try(EVP_CipherUpdate(xctx->ctx,
				     xctx->e, &outl,
				     xctx->m, bl),
		    "cipher update error (finalizing)", return0);
	memcpy(out, xctx->e, bl);

	return 1;

return0:
	return 0;
}
开发者ID:grivet,项目名称:XCBC,代码行数:30,代码来源:xcbc.c


示例6: writeSize

	/*
		the size of outBuf must be larger than inBufSize + blockSize
		@retval positive or 0 : writeSize(+blockSize)
		@retval -1 : error
	*/
	int update(char *outBuf, const char *inBuf, int inBufSize)
	{
		int outLen = 0;
		int ret = EVP_CipherUpdate(&ctx_, cybozu::cast<uint8_t*>(outBuf), &outLen, cybozu::cast<const uint8_t*>(inBuf), inBufSize);
		if (ret != 1) return -1;
		return outLen;
	}
开发者ID:pombredanne,项目名称:cybozulib,代码行数:12,代码来源:crypto.hpp


示例7: encryptfile

void encryptfile(FILE * fpin,FILE* fpout,unsigned char* key, unsigned char* iv)
{
	//Using openssl EVP to encrypt a file

	
	const unsigned bufsize = 4096;
	unsigned char* read_buf = malloc(bufsize);
	unsigned char* cipher_buf ;
	unsigned blocksize;
	int out_len;

	EVP_CIPHER_CTX ctx;

	EVP_CipherInit(&ctx,EVP_aes_256_cbc(),key,iv,1);
	blocksize = EVP_CIPHER_CTX_block_size(&ctx);
	cipher_buf = malloc(bufsize+blocksize);

	// read file and write encrypted file until eof
	while(1)
	{
		int bytes_read = fread(read_buf,sizeof(unsigned char),bufsize,fpin);
		EVP_CipherUpdate(&ctx,cipher_buf,&out_len,read_buf, bytes_read);
		fwrite(cipher_buf,sizeof(unsigned char),out_len,fpout);
		if(bytes_read < bufsize)
		{
			break;//EOF
		}
	}

	EVP_CipherFinal(&ctx,cipher_buf,&out_len);
	fwrite(cipher_buf,sizeof(unsigned char),out_len,fpout);

	free(cipher_buf);
	free(read_buf);
}
开发者ID:roothaxor,项目名称:Ransom,代码行数:35,代码来源:encrypter.c


示例8: cipher_context_update

static int cipher_context_update(cipher_ctx_t *ctx, uint8_t *output, size_t *olen,
                                 const uint8_t *input, size_t ilen)
{
#ifdef USE_CRYPTO_APPLECC
    cipher_cc_t *cc = &ctx->cc;
    if (cc->valid == kCCContextValid) {
        CCCryptorStatus ret;
        ret = CCCryptorUpdate(cc->cryptor, input, ilen, output,
                              ilen, olen);
        return (ret == kCCSuccess) ? 1 : 0;
    }
#endif
    cipher_evp_t *evp = &ctx->evp;
#if defined(USE_CRYPTO_OPENSSL)
    int err = 0, tlen = *olen;
    err = EVP_CipherUpdate(evp, (uint8_t *)output, &tlen,
                           (const uint8_t *)input, ilen);
    *olen = tlen;
    return err;
#elif defined(USE_CRYPTO_POLARSSL)
    return !cipher_update(evp, (const uint8_t *)input, ilen,
                          (uint8_t *)output, olen);
#elif defined(USE_CRYPTO_MBEDTLS)
    return !mbedtls_cipher_update(evp, (const uint8_t *)input, ilen,
                                  (uint8_t *)output, olen);
#endif
}
开发者ID:3gao,项目名称:shadowsocks-libev,代码行数:27,代码来源:encrypt.c


示例9: do_crypt

/********************do the cryption part*************************/
int do_crypt(unsigned char *key, unsigned char *iv, char *msg, int *l, int crypt) {
    unsigned char outbuf[BUFSIZE + EVP_MAX_BLOCK_LENGTH];
    int len = *l, outlen, tmplen, i;
    unsigned char input[BUFSIZE];
    
    memcpy(input, msg, len);
    if (DEBUG) {
   	 printf("\nbefore crypted payload: ");
   	 for(i = 0; i < len; i++) printf("%02x", *(input+i));
   	 putchar(10);
    }

    EVP_CIPHER_CTX ctx;
    EVP_CIPHER_CTX_init(&ctx);
    EVP_CipherInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key, iv, crypt);

    if(!EVP_CipherUpdate(&ctx, outbuf, &outlen, input, len)) {
   	 EVP_CIPHER_CTX_cleanup(&ctx);
   	 return 0;
    }
    if(!EVP_CipherFinal_ex(&ctx, outbuf + outlen, &tmplen)) {
   	 EVP_CIPHER_CTX_cleanup(&ctx);
   	 return 0;
    }
    outlen += tmplen;
    if (DEBUG) {
   	 printf("\ncrypted payload: ");
   	 for(i = 0; i < outlen; i++) printf("%02x", *(outbuf+i));
   	 printf("\n");
    }
    memcpy(msg, outbuf, outlen);
    *l = outlen;
    EVP_CIPHER_CTX_cleanup(&ctx);
    return 1;    
}
开发者ID:jeffjee617,项目名称:secureVPN,代码行数:36,代码来源:fun.c


示例10: run

void run(const char *name, unsigned char *buf, int len) {
	int pass = TOTAL_LEN / len;
	
	unsigned char key[32] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
		0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F};
	
	EVP_CIPHER_CTX ctx;
	EVP_CIPHER_CTX_init(&ctx);
	
	int outlen = 0;
	struct timeval start, end;
	double total_time, throughput;
	
	EVP_CIPHER *cipher = (EVP_CIPHER *) EVP_get_cipherbyname("aes-256-ecb");
	
	EVP_CipherInit_ex(&ctx, cipher, NULL, key, NULL, 1);
	
	gettimeofday(&start, NULL);
	for (int i = 0; i < pass; i++) {
		fprintf(stderr, "%s: Pass %d/%d\n", name, i + 1, pass);
		// note we cannot run multiple pass on the same buffer, the CPU will cache it! (smart bastards at Intel)
		EVP_CipherUpdate(&ctx, buf + i * len, &outlen, buf, len);
		if (len != outlen) {
			fprintf(stderr, "Fatal error: incorrect output size.\n");
		}
	}
	
	gettimeofday(&end, NULL);
	total_time = end.tv_sec - start.tv_sec + (end.tv_usec - start.tv_usec) / 1000000.0;
	throughput = TOTAL_LEN * 8 / total_time / 1000000;
	printf("%s: %u-byte blocks, %lubytes in %f s, Throughput: %fMbps\n", name, len, TOTAL_LEN, total_time, throughput);
	
	EVP_CIPHER_CTX_cleanup(&ctx);
}
开发者ID:Optiminer,项目名称:OpenCL-AES,代码行数:34,代码来源:benchmark.c


示例11: crypt

int crypt(unsigned char *inbuf, int inlen, unsigned char *outbuf, unsigned char key[],unsigned char iv[], int do_encrypt)
        {

        int outlen, mlen;

	
	EVP_CIPHER_CTX ctx;
        EVP_CIPHER_CTX_init(&ctx);
        EVP_CipherInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key, iv, do_encrypt);
	outlen = 0;

        if(inlen <= 0) return 0;
        if(!EVP_CipherUpdate(&ctx, outbuf + outlen, &mlen, inbuf, inlen))
        {
                /* Error */
        	EVP_CIPHER_CTX_cleanup(&ctx);
        	return 0;
        }
	outlen += mlen;
        if(!EVP_CipherFinal_ex(&ctx, outbuf + outlen, &mlen))
                {
                /* Error */
                EVP_CIPHER_CTX_cleanup(&ctx);
                return 0;
                }
	outlen += mlen;
        EVP_CIPHER_CTX_cleanup(&ctx);
        return outlen;
        }
开发者ID:zhuzhu9910,项目名称:AcademicProjects,代码行数:29,代码来源:utilities.c


示例12: Java_com_facebook_crypto_cipher_NativeGCMCipher_nativeUpdate

JNIEXPORT int JNICALL Java_com_facebook_crypto_cipher_NativeGCMCipher_nativeUpdate(
  JNIEnv* env,
  jobject obj,
  jbyteArray data,
  jint offset,
  jint dataLength,
  jbyteArray output) {

  int bytesWritten = 0;
  EVP_CIPHER_CTX* ctx = Get_Cipher_CTX(env, obj);
  if (!ctx) {
    return CRYPTO_NO_BYTES_WRITTEN;
  }

  jbyte* outputBytes = (*env)->GetByteArrayElements(env, output, NULL);
  if (!outputBytes) {
    return CRYPTO_NO_BYTES_WRITTEN;
  }

  jbyte* dataBytes = (*env)->GetByteArrayElements(env, data, NULL);
  if (!dataBytes) {
    (*env)->ReleaseByteArrayElements(env, output, outputBytes, 0);
    return CRYPTO_NO_BYTES_WRITTEN;
  }

  if (!EVP_CipherUpdate(ctx, outputBytes, &bytesWritten, dataBytes + offset, dataLength)) {
    bytesWritten = CRYPTO_NO_BYTES_WRITTEN;
  }

  (*env)->ReleaseByteArrayElements(env, data, dataBytes, JNI_ABORT);
  (*env)->ReleaseByteArrayElements(env, output, outputBytes, 0);

  return bytesWritten;
}
开发者ID:0359xiaodong,项目名称:conceal,代码行数:34,代码来源:gcm.c


示例13: ossl_cipher_update

/*
 *  call-seq:
 *     cipher.update(data [, buffer]) -> string or buffer
 *
 *  === Parameters
 *  +data+ is a nonempty string.
 *  +buffer+ is an optional string to store the result.
 */
static VALUE 
ossl_cipher_update(int argc, VALUE *argv, VALUE self)
{
    EVP_CIPHER_CTX *ctx;
    char *in;
    int in_len, out_len;
    VALUE data, str;

    rb_scan_args(argc, argv, "11", &data, &str);

    StringValue(data);
    in = RSTRING_PTR(data);
    if ((in_len = RSTRING_LEN(data)) == 0)
        rb_raise(rb_eArgError, "data must not be empty");
    GetCipher(self, ctx);
    out_len = in_len+EVP_CIPHER_CTX_block_size(ctx);

    if (NIL_P(str)) {
        str = rb_str_new(0, out_len);
    } else {
        StringValue(str);
        rb_str_resize(str, out_len);
    }

    if (!EVP_CipherUpdate(ctx, RSTRING_PTR(str), &out_len, in, in_len))
	ossl_raise(eCipherError, NULL);
    assert(out_len < RSTRING_LEN(str));
    rb_str_set_len(str, out_len);

    return str;
}
开发者ID:AdamDotCom,项目名称:my-rvm,代码行数:39,代码来源:ossl_cipher.c


示例14: sb_aes_crypt

static int sb_aes_crypt(struct sb_image_ctx *ictx, uint8_t *in_data,
			uint8_t *out_data, int in_len)
{
	EVP_CIPHER_CTX *ctx = &ictx->cipher_ctx;
	int ret, outlen;
	uint8_t *outbuf;

	outbuf = malloc(in_len);
	if (!outbuf)
		return -ENOMEM;
	memset(outbuf, 0, sizeof(in_len));

	ret = EVP_CipherUpdate(ctx, outbuf, &outlen, in_data, in_len);
	if (!ret) {
		ret = -EINVAL;
		goto err;
	}

	if (out_data)
		memcpy(out_data, outbuf, outlen);

err:
	free(outbuf);
	return ret;
}
开发者ID:DeviceSolutions,项目名称:u-boot-opal6,代码行数:25,代码来源:mxsimage.c


示例15: EVP_CIPHER_CTX_init

bool CryptoBuffer::doCrypt(const char *in, int inlen, bool isEncrypt, QByteArray &out)
{
  const int OUTBUF_SIZE = 8*1024;
  unsigned char outbuf[OUTBUF_SIZE + EVP_MAX_BLOCK_LENGTH];

  EVP_CIPHER_CTX ctx;
  EVP_CIPHER_CTX_init(&ctx);
  auto ctxGuard = makeGuard([&ctx] { EVP_CIPHER_CTX_cleanup(&ctx); });

  if (!EVP_CipherInit_ex(&ctx, d->cipher, NULL, d->key, d->iv, isEncrypt))
    return DEBUGRET(false, "EVP_CipherInit_Ex failed");

  const unsigned char *ptr = reinterpret_cast<const unsigned char*>(in);
  int restlen = inlen;
  int outlen;

  while (restlen > 0)
  {
    int readlen = std::min(restlen, OUTBUF_SIZE);
    if (!EVP_CipherUpdate(&ctx, outbuf, &outlen, ptr, readlen))
      return DEBUGRET(false, "EVP_CipherUpdate failed");

    out.append(reinterpret_cast<const char*>(outbuf), outlen);
    ptr += readlen;
    restlen -= readlen;
  }

  if (!EVP_CipherFinal_ex(&ctx, outbuf, &outlen))
    return DEBUGRET(false, "EVP_CipherFinal_ex failed");
  out.append(reinterpret_cast<const char*>(outbuf), outlen);

  return true;
}
开发者ID:rndCombo,项目名称:contestants_code_BIBIFI,代码行数:33,代码来源:CryptoBuffer.cpp


示例16: while

size_t Cipher::put(const uint8_t *data, size_t size)
{
    int outlen;
    size_t count = 0;

    if(!bufaddr)
        return 0;

    if(size % keys.iosize())
        return 0;

    while(bufsize && size + bufpos > bufsize) {
        size_t diff = bufsize - bufpos;
        count += put(data, diff);
        data += diff;
        size -= diff;
    }

    if(!EVP_CipherUpdate((EVP_CIPHER_CTX *)context, bufaddr + bufpos, &outlen, data, (int)size)) {
        release();
        return count;
    }
    bufpos += outlen;
    count += outlen;
    if(bufsize && bufpos >= bufsize) {
        push(bufaddr, bufsize);
        bufpos = 0;
    }
    return count;
}
开发者ID:oudream,项目名称:ucommon,代码行数:30,代码来源:cipher.cpp


示例17: do_cipher

static int
do_cipher(EVP_CIPHER_CTX *cipher_ctx, const u8 *in, size_t in_len,
		u8 **out, size_t *out_len)
{
	const u8 *end;
	u8	*p;
	size_t	bl, done, left, total;

	*out = p = (u8 *) malloc(in_len + EVP_CIPHER_CTX_key_length(cipher_ctx));
	*out_len = total = 0;

	bl = EVP_CIPHER_CTX_block_size(cipher_ctx);
	end = in + in_len;
	while (in < end) {
		if ((left = end - in) > bl)
			left = bl;
		if (!EVP_CipherUpdate(cipher_ctx,
					p + total, (int *) &done,
					(u8 *) in, (int)left))
			goto fail;
		total += done;
		in += left;
	}
	if (1 || total < in_len) {
		if (!EVP_CipherFinal(cipher_ctx, p + total, (int *) &done))
			goto fail;
		total += done;
	}
	*out_len = total;
	return 0;

fail:	free(p);
	return SC_ERROR_INTERNAL;
}
开发者ID:guadalinex-archive,项目名称:guadalinex-v5,代码行数:34,代码来源:pkcs15-wrap.c


示例18: LUA_FUNCTION

/* evp_cipher_ctx method */
static LUA_FUNCTION(openssl_evp_cipher_update)
{
  EVP_CIPHER_CTX* c = CHECK_OBJECT(1, EVP_CIPHER_CTX, "openssl.evp_cipher_ctx");
  size_t inl;
  const char* in = luaL_checklstring(L, 2, &inl);
  int outl = inl + EVP_MAX_BLOCK_LENGTH;
  char* out = OPENSSL_malloc(outl);
  CIPHER_MODE mode;
  int ret = 0;

  lua_rawgetp(L, LUA_REGISTRYINDEX, c);
  mode = lua_tointeger(L, -1);

  if (mode == DO_CIPHER)
    ret = EVP_CipherUpdate(c, (byte*)out, &outl, (const byte*)in, inl);
  else if (mode == DO_ENCRYPT)
    ret = EVP_EncryptUpdate(c, (byte*)out, &outl, (const byte*)in, inl);
  else if (mode == DO_DECRYPT)
    ret = EVP_DecryptUpdate(c, (byte*)out, &outl, (const byte*)in, inl);
  else
    luaL_error(L, "never go here");
  lua_pop(L, 1);

  if (ret == 1)
  {
    lua_pushlstring(L, out, outl);
  }
  OPENSSL_free(out);

  return (ret == 1 ? ret : openssl_pushresult(L, ret));
}
开发者ID:world100,项目名称:11111,代码行数:32,代码来源:cipher.c


示例19: enc_write

static int enc_write(BIO *b, const char *in, int inl)
{
    int ret = 0, n, i;
    BIO_ENC_CTX *ctx;
    BIO *next;

    ctx = BIO_get_data(b);
    next = BIO_next(b);
    if ((ctx == NULL) || (next == NULL))
        return 0;

    ret = inl;

    BIO_clear_retry_flags(b);
    n = ctx->buf_len - ctx->buf_off;
    while (n > 0) {
        i = BIO_write(next, &(ctx->buf[ctx->buf_off]), n);
        if (i <= 0) {
            BIO_copy_next_retry(b);
            return (i);
        }
        ctx->buf_off += i;
        n -= i;
    }
    /* at this point all pending data has been written */

    if ((in == NULL) || (inl <= 0))
        return (0);

    ctx->buf_off = 0;
    while (inl > 0) {
        n = (inl > ENC_BLOCK_SIZE) ? ENC_BLOCK_SIZE : inl;
        if (!EVP_CipherUpdate(ctx->cipher,
                              ctx->buf, &ctx->buf_len,
                              (const unsigned char *)in, n)) {
            BIO_clear_retry_flags(b);
            ctx->ok = 0;
            return 0;
        }
        inl -= n;
        in += n;

        ctx->buf_off = 0;
        n = ctx->buf_len;
        while (n > 0) {
            i = BIO_write(next, &(ctx->buf[ctx->buf_off]), n);
            if (i <= 0) {
                BIO_copy_next_retry(b);
                return (ret == inl) ? i : ret - inl;
            }
            n -= i;
            ctx->buf_off += i;
        }
        ctx->buf_len = 0;
        ctx->buf_off = 0;
    }
    BIO_copy_next_retry(b);
    return (ret);
}
开发者ID:Muffo,项目名称:openssl,代码行数:59,代码来源:bio_enc.c


示例20: cipher_ctx_update

int
cipher_ctx_update (EVP_CIPHER_CTX *ctx, uint8_t *dst, int *dst_len,
    uint8_t *src, int src_len)
{
  if (!EVP_CipherUpdate (ctx, dst, dst_len, src, src_len))
    crypto_msg(M_FATAL, "%s: EVP_CipherUpdate() failed", __func__);
  return 1;
}
开发者ID:746bce42110a11028656eca33867,项目名称:openvpn,代码行数:8,代码来源:crypto_openssl.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ EVP_DecryptFinal_ex函数代码示例发布时间:2022-05-30
下一篇:
C++ EVP_CipherInit_ex函数代码示例发布时间: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