• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/ruby-106/ruby/ext/openssl/

Lines Matching refs:ctx

13 #define WrapCipher(obj, klass, ctx) \
14 (obj) = Data_Wrap_Struct((klass), 0, ossl_cipher_free, (ctx))
15 #define MakeCipher(obj, klass, ctx) \
16 (obj) = Data_Make_Struct((klass), EVP_CIPHER_CTX, 0, ossl_cipher_free, (ctx))
17 #define AllocCipher(obj, ctx) \
18 memset(DATA_PTR(obj) = (ctx) = ALLOC(EVP_CIPHER_CTX), 0, sizeof(EVP_CIPHER_CTX))
19 #define GetCipherInit(obj, ctx) do { \
20 Data_Get_Struct((obj), EVP_CIPHER_CTX, (ctx)); \
22 #define GetCipher(obj, ctx) do { \
23 GetCipherInit((obj), (ctx)); \
24 if (!(ctx)) { \
28 #define SafeGetCipher(obj, ctx) do { \
30 GetCipher((obj), (ctx)); \
47 EVP_CIPHER_CTX *ctx;
49 SafeGetCipher(obj, ctx);
51 return EVP_CIPHER_CTX_cipher(ctx);
58 EVP_CIPHER_CTX *ctx;
61 AllocCipher(ret, ctx);
62 EVP_CIPHER_CTX_init(ctx);
63 if (EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, -1) != 1)
73 ossl_cipher_free(EVP_CIPHER_CTX *ctx)
75 if (ctx) {
76 EVP_CIPHER_CTX_cleanup(ctx);
77 ruby_xfree(ctx);
102 EVP_CIPHER_CTX *ctx;
108 GetCipherInit(self, ctx);
109 if (ctx) {
112 AllocCipher(self, ctx);
113 EVP_CIPHER_CTX_init(ctx);
124 if (EVP_CipherInit_ex(ctx, cipher, NULL, key, NULL, -1) != 1)
188 * Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, -1).
193 EVP_CIPHER_CTX *ctx;
195 GetCipher(self, ctx);
196 if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, -1) != 1)
205 EVP_CIPHER_CTX *ctx;
221 GetCipher(self, ctx);
231 EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), EVP_md5(), iv,
237 GetCipher(self, ctx);
239 if (EVP_CipherInit_ex(ctx, NULL, NULL, p_key, p_iv, mode) != 1) {
256 * Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, 1).
274 * Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, 0).
305 EVP_CIPHER_CTX *ctx;
321 GetCipher(self, ctx);
322 EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), digest, salt,
324 if (EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, -1) != 1)
348 EVP_CIPHER_CTX *ctx;
359 GetCipher(self, ctx);
360 out_len = in_len+EVP_CIPHER_CTX_block_size(ctx);
369 if (!EVP_CipherUpdate(ctx, (unsigned char *)RSTRING_PTR(str), &out_len, in, in_len))
394 EVP_CIPHER_CTX *ctx;
398 GetCipher(self, ctx);
399 str = rb_str_new(0, EVP_CIPHER_CTX_block_size(ctx));
400 if (!EVP_CipherFinal_ex(ctx, (unsigned char *)RSTRING_PTR(str), &out_len))
418 EVP_CIPHER_CTX *ctx;
420 GetCipher(self, ctx);
422 return rb_str_new2(EVP_CIPHER_name(EVP_CIPHER_CTX_cipher(ctx)));
439 EVP_CIPHER_CTX *ctx;
442 GetCipher(self, ctx);
444 if (RSTRING_LEN(key) < EVP_CIPHER_CTX_key_length(ctx))
447 if (EVP_CipherInit_ex(ctx, NULL, NULL, (unsigned char *)RSTRING_PTR(key), NULL, -1) != 1)
471 EVP_CIPHER_CTX *ctx;
474 GetCipher(self, ctx);
476 if (RSTRING_LEN(iv) < EVP_CIPHER_CTX_iv_length(ctx))
479 if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, (unsigned char *)RSTRING_PTR(iv), -1) != 1)
507 EVP_CIPHER_CTX *ctx;
517 GetCipher(self, ctx);
519 if (!EVP_CipherUpdate(ctx, NULL, &out_len, in, in_len))
530 ossl_get_gcm_auth_tag(EVP_CIPHER_CTX *ctx, int len)
537 if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, len, tag))
563 EVP_CIPHER_CTX *ctx;
572 GetCipher(self, ctx);
573 nid = EVP_CIPHER_CTX_nid(ctx);
576 return ossl_get_gcm_auth_tag(ctx, tag_len);
584 ossl_set_gcm_auth_tag(EVP_CIPHER_CTX *ctx, unsigned char *tag, int tag_len)
586 if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, tag_len, tag))
605 EVP_CIPHER_CTX *ctx;
614 GetCipher(self, ctx);
615 nid = EVP_CIPHER_CTX_nid(ctx);
618 ossl_set_gcm_auth_tag(ctx, tag, tag_len);
636 EVP_CIPHER_CTX *ctx;
639 GetCipher(self, ctx);
640 nid = EVP_CIPHER_CTX_nid(ctx);
671 EVP_CIPHER_CTX *ctx;
673 GetCipher(self, ctx);
674 if (EVP_CIPHER_CTX_set_key_length(ctx, len) != 1)
694 EVP_CIPHER_CTX *ctx;
697 GetCipher(self, ctx);
698 if (EVP_CIPHER_CTX_set_padding(ctx, pad) != 1)
710 EVP_CIPHER_CTX *ctx; \
711 GetCipher(self, ctx); \
712 return INT2NUM(EVP_CIPHER_##func(EVP_CIPHER_CTX_cipher(ctx))); \