Lines Matching refs:ctx

55 static void kdf_scrypt_init(KDF_SCRYPT *ctx);
59 KDF_SCRYPT *ctx;
64 ctx = OPENSSL_zalloc(sizeof(*ctx));
65 if (ctx == NULL) {
69 ctx->libctx = PROV_LIBCTX_OF(provctx);
70 kdf_scrypt_init(ctx);
71 return ctx;
76 KDF_SCRYPT *ctx = (KDF_SCRYPT *)vctx;
78 if (ctx != NULL) {
79 OPENSSL_free(ctx->propq);
80 EVP_MD_free(ctx->sha256);
81 kdf_scrypt_reset(ctx);
82 OPENSSL_free(ctx);
88 KDF_SCRYPT *ctx = (KDF_SCRYPT *)vctx;
90 OPENSSL_free(ctx->salt);
91 OPENSSL_clear_free(ctx->pass, ctx->pass_len);
92 kdf_scrypt_init(ctx);
95 static void kdf_scrypt_init(KDF_SCRYPT *ctx)
101 ctx->N = 1 << 20;
102 ctx->r = 8;
103 ctx->p = 1;
104 ctx->maxmem_bytes = 1025 * 1024 * 1024;
126 static int set_digest(KDF_SCRYPT *ctx)
128 EVP_MD_free(ctx->sha256);
129 ctx->sha256 = EVP_MD_fetch(ctx->libctx, "sha256", ctx->propq);
130 if (ctx->sha256 == NULL) {
131 OPENSSL_free(ctx);
138 static int set_property_query(KDF_SCRYPT *ctx, const char *propq)
140 OPENSSL_free(ctx->propq);
141 ctx->propq = NULL;
143 ctx->propq = OPENSSL_strdup(propq);
144 if (ctx->propq == NULL) {
155 KDF_SCRYPT *ctx = (KDF_SCRYPT *)vctx;
157 if (!ossl_prov_is_running() || !kdf_scrypt_set_ctx_params(ctx, params))
160 if (ctx->pass == NULL) {
165 if (ctx->salt == NULL) {
170 if (ctx->sha256 == NULL && !set_digest(ctx))
173 return scrypt_alg((char *)ctx->pass, ctx->pass_len, ctx->salt,
174 ctx->salt_len, ctx->N, ctx->r, ctx->p,
175 ctx->maxmem_bytes, key, keylen, ctx->sha256,
176 ctx->libctx, ctx->propq);
187 KDF_SCRYPT *ctx = vctx;
194 if (!scrypt_set_membuf(&ctx->pass, &ctx->pass_len, p))
198 if (!scrypt_set_membuf(&ctx->salt, &ctx->salt_len, p))
207 ctx->N = u64_value;
214 ctx->r = u64_value;
221 ctx->p = u64_value;
228 ctx->maxmem_bytes = u64_value;
234 || !set_property_query(ctx, p->data)
235 || !set_digest(ctx))
241 static const OSSL_PARAM *kdf_scrypt_settable_ctx_params(ossl_unused void *ctx,
266 static const OSSL_PARAM *kdf_scrypt_gettable_ctx_params(ossl_unused void *ctx,