Lines Matching refs:ctx

220 	struct krb5_ctx *ctx, struct crypto_blkcipher **res)
248 *res = crypto_alloc_blkcipher(ctx->gk5e->encrypt_name, 0,
252 "crypto algorithm %s\n", ctx->gk5e->encrypt_name);
258 "crypto algorithm %s\n", ctx->gk5e->encrypt_name);
275 gss_import_v1_context(const void *p, const void *end, struct krb5_ctx *ctx)
279 p = simple_get_bytes(p, end, &ctx->initiate, sizeof(ctx->initiate));
284 ctx->enctype = ENCTYPE_DES_CBC_RAW;
286 ctx->gk5e = get_gss_krb5_enctype(ctx->enctype);
287 if (ctx->gk5e == NULL) {
315 p = simple_get_bytes(p, end, &ctx->endtime, sizeof(ctx->endtime));
318 p = simple_get_bytes(p, end, &ctx->seq_send, sizeof(ctx->seq_send));
321 p = simple_get_netobj(p, end, &ctx->mech_used);
324 p = get_key(p, end, ctx, &ctx->enc);
327 p = get_key(p, end, ctx, &ctx->seq);
338 crypto_free_blkcipher(ctx->seq);
340 crypto_free_blkcipher(ctx->enc);
342 kfree(ctx->mech_used.data);
348 context_v2_alloc_cipher(struct krb5_ctx *ctx, const char *cname, u8 *key)
358 if (crypto_blkcipher_setkey(cp, key, ctx->gk5e->keylength)) {
378 context_derive_keys_des3(struct krb5_ctx *ctx, gfp_t gfp_mask)
387 keyin.data = ctx->Ksess;
388 keyin.len = ctx->gk5e->keylength;
389 keyout.len = ctx->gk5e->keylength;
392 ctx->seq = context_v2_alloc_cipher(ctx, ctx->gk5e->encrypt_name,
393 ctx->Ksess);
394 if (ctx->seq == NULL)
397 ctx->enc = context_v2_alloc_cipher(ctx, ctx->gk5e->encrypt_name,
398 ctx->Ksess);
399 if (ctx->enc == NULL)
404 keyout.data = ctx->cksum;
405 err = krb5_derive_key(ctx->gk5e, &keyin, &keyout, &c, gfp_mask);
415 crypto_free_blkcipher(ctx->enc);
417 crypto_free_blkcipher(ctx->seq);
428 context_derive_keys_rc4(struct krb5_ctx *ctx)
441 hmac = crypto_alloc_hash(ctx->gk5e->cksum_name, 0, CRYPTO_ALG_ASYNC);
444 __func__, PTR_ERR(hmac), ctx->gk5e->cksum_name);
449 err = crypto_hash_setkey(hmac, ctx->Ksess, ctx->gk5e->keylength);
463 err = crypto_hash_digest(&desc, sg, slen, ctx->cksum);
469 ctx->enc = crypto_alloc_blkcipher(ctx->gk5e->encrypt_name, 0,
471 if (IS_ERR(ctx->enc)) {
472 err = PTR_ERR(ctx->enc);
476 ctx->seq = crypto_alloc_blkcipher(ctx->gk5e->encrypt_name, 0,
478 if (IS_ERR(ctx->seq)) {
479 crypto_free_blkcipher(ctx->enc);
480 err = PTR_ERR(ctx->seq);
496 context_derive_keys_new(struct krb5_ctx *ctx, gfp_t gfp_mask)
505 keyin.data = ctx->Ksess;
506 keyin.len = ctx->gk5e->keylength;
507 keyout.len = ctx->gk5e->keylength;
511 keyout.data = ctx->initiator_seal;
512 err = krb5_derive_key(ctx->gk5e, &keyin, &keyout, &c, gfp_mask);
518 ctx->initiator_enc = context_v2_alloc_cipher(ctx,
519 ctx->gk5e->encrypt_name,
520 ctx->initiator_seal);
521 if (ctx->initiator_enc == NULL)
526 keyout.data = ctx->acceptor_seal;
527 err = krb5_derive_key(ctx->gk5e, &keyin, &keyout, &c, gfp_mask);
533 ctx->acceptor_enc = context_v2_alloc_cipher(ctx,
534 ctx->gk5e->encrypt_name,
535 ctx->acceptor_seal);
536 if (ctx->acceptor_enc == NULL)
541 keyout.data = ctx->initiator_sign;
542 err = krb5_derive_key(ctx->gk5e, &keyin, &keyout, &c, gfp_mask);
551 keyout.data = ctx->acceptor_sign;
552 err = krb5_derive_key(ctx->gk5e, &keyin, &keyout, &c, gfp_mask);
561 keyout.data = ctx->initiator_integ;
562 err = krb5_derive_key(ctx->gk5e, &keyin, &keyout, &c, gfp_mask);
571 keyout.data = ctx->acceptor_integ;
572 err = krb5_derive_key(ctx->gk5e, &keyin, &keyout, &c, gfp_mask);
579 switch (ctx->enctype) {
582 ctx->initiator_enc_aux =
583 context_v2_alloc_cipher(ctx, "cbc(aes)",
584 ctx->initiator_seal);
585 if (ctx->initiator_enc_aux == NULL)
587 ctx->acceptor_enc_aux =
588 context_v2_alloc_cipher(ctx, "cbc(aes)",
589 ctx->acceptor_seal);
590 if (ctx->acceptor_enc_aux == NULL) {
591 crypto_free_blkcipher(ctx->initiator_enc_aux);
599 crypto_free_blkcipher(ctx->acceptor_enc);
601 crypto_free_blkcipher(ctx->initiator_enc);
607 gss_import_v2_context(const void *p, const void *end, struct krb5_ctx *ctx,
612 p = simple_get_bytes(p, end, &ctx->flags, sizeof(ctx->flags));
615 ctx->initiate = ctx->flags & KRB5_CTX_FLAG_INITIATOR;
617 p = simple_get_bytes(p, end, &ctx->endtime, sizeof(ctx->endtime));
620 p = simple_get_bytes(p, end, &ctx->seq_send64, sizeof(ctx->seq_send64));
624 ctx->seq_send = ctx->seq_send64;
625 if (ctx->seq_send64 != ctx->seq_send) {
627 (unsigned long)ctx->seq_send64, ctx->seq_send);
631 p = simple_get_bytes(p, end, &ctx->enctype, sizeof(ctx->enctype));
635 if (ctx->enctype == ENCTYPE_DES3_CBC_SHA1)
636 ctx->enctype = ENCTYPE_DES3_CBC_RAW;
637 ctx->gk5e = get_gss_krb5_enctype(ctx->enctype);
638 if (ctx->gk5e == NULL) {
640 ctx->enctype);
644 keylen = ctx->gk5e->keylength;
646 p = simple_get_bytes(p, end, ctx->Ksess, keylen);
655 ctx->mech_used.data = kmemdup(gss_kerberos_mech.gm_oid.data,
657 if (unlikely(ctx->mech_used.data == NULL)) {
661 ctx->mech_used.len = gss_kerberos_mech.gm_oid.len;
663 switch (ctx->enctype) {
665 return context_derive_keys_des3(ctx, gfp_mask);
667 return context_derive_keys_rc4(ctx);
670 return context_derive_keys_new(ctx, gfp_mask);
686 struct krb5_ctx *ctx;
689 ctx = kzalloc(sizeof(*ctx), gfp_mask);
690 if (ctx == NULL)
694 ret = gss_import_v1_context(p, end, ctx);
696 ret = gss_import_v2_context(p, end, ctx, gfp_mask);
699 ctx_id->internal_ctx_id = ctx;
701 *endtime = ctx->endtime;
703 kfree(ctx);