/* SPDX-License-Identifier: GPL-2.0-or-later */ /* Common bits for GSSAPI-based RxRPC security. * * Copyright (C) 2025 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com)
*/
/* * Per-key number context. This is replaced when the connection is rekeyed.
*/ struct rxgk_context {
refcount_t usage; unsignedint key_number; /* Rekeying number (goes in the rx header) */ unsignedlong flags; #define RXGK_TK_NEEDS_REKEY 0 /* Set if this needs rekeying */ unsignedlong expiry; /* Expiration time of this key */ longlong bytes_remaining; /* Remaining Tx lifetime of this key */ conststruct krb5_enctype *krb5; /* RxGK encryption type */ conststruct rxgk_key *key;
/* We need up to 7 keys derived from the transport key, but we don't * actually need the transport key. Each key is derived by * DK(TK,constant).
*/ struct crypto_aead *tx_enc; /* Transmission key */ struct crypto_aead *rx_enc; /* Reception key */ struct crypto_shash *tx_Kc; /* Transmission checksum key */ struct crypto_shash *rx_Kc; /* Reception checksum key */ struct crypto_aead *resp_enc; /* Response packet enc key */
};
/* * Apply decryption and checksumming functions to part of an skbuff. The * offset and length are updated to reflect the actual content of the encrypted * region.
*/ staticinline int rxgk_decrypt_skb(conststruct krb5_enctype *krb5, struct crypto_aead *aead, struct sk_buff *skb, unsignedint *_offset, unsignedint *_len, int *_error_code)
{ struct scatterlist sg[16];
size_t offset = 0, len = *_len; int nr_sg, ret;
ret = crypto_krb5_decrypt(krb5, aead, sg, nr_sg,
&offset, &len); switch (ret) { case 0:
*_offset += offset;
*_len = len; break; case -EBADMSG: /* Checksum mismatch. */ case -EPROTO:
*_error_code = RXGK_SEALEDINCON; break; case -EMSGSIZE:
*_error_code = RXGK_PACKETSHORT; break; case -ENOPKG: /* Would prefer RXGK_BADETYPE, but not available for YFS. */ default:
*_error_code = RXGK_INCONSISTENCY; break;
}
return ret;
}
/* * Check the MIC on a region of an skbuff. The offset and length are updated * to reflect the actual content of the secure region.
*/ staticinline int rxgk_verify_mic_skb(conststruct krb5_enctype *krb5, struct crypto_shash *shash, conststruct krb5_buffer *metadata, struct sk_buff *skb, unsignedint *_offset, unsignedint *_len,
u32 *_error_code)
{ struct scatterlist sg[16];
size_t offset = 0, len = *_len; int nr_sg, ret;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.