Hi Herbert, Chuck, Here's my next go at a generic Kerberos crypto library in the kernel so that I can share code between rxrpc and sunrpc (and cifs?). I derived some of the parts from the sunrpc gss library and added more advanced AES and Camellia crypto. The crypto bits are inside AEAD algorithms as Herbert required, but there's also a library of supplementary functions to aid in managing message layout. You can use: const struct krb5_enctype *crypto_krb5_find_enctype(u32 enctype); to go and get an information table and this will also let you get at the name of the AEAD algorithm associated with that encoding type number. Each AEAD algorithm is defined for a particular Kerberos 5 type by name (not by enctype number) and supports both encryption and checksumming (MIC) through the AEAD encrypt/decrypt request API. Note that the plain text may be a different size to the cipher text and this causes the testmgr some issues as it thinks the extra data is an auth tag (but this doesn't want auth tags). A kerberos AEAD object is configured through its setkey method and this takes a compound structure that indicates the mode of operation (encrypt or checksum), the usage type and either the transport key or the subkeys. The setkey method allocates and keys the constituent ciphers and hashes - but that's a detail hidden inside the object. This library has its own self-testing framework that checks more things than is possible with the testmgr, including subkey derivation. It also checks things about the output of encrypt + decrypt that testmgr doesn't. That said, testmgr is also provisioned with some encryption and checksumming tests for Camilla and AES2. Note that, for purposes of illustration, I've included some rxrpc patches that use this interface to implement the rxgk Rx security class. The branch also is based on net-next that carries some rxrpc patches that are a prerequisite for this, but the crypto patches don't need it. --- The patches can be found here also: http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/log/?h=crypto-krb5 David David Howells (8): crypto/krb5: Add some constants out of sunrpc headers crypto/krb5: Provide Kerberos 5 crypto through AEAD API crypto/krb5: Test manager data rxrpc: Add the security index for yfs-rxgk rxrpc: Add YFS RxGK (GSSAPI) security class rxrpc: rxgk: Provide infrastructure and key derivation rxrpc: rxgk: Implement the yfs-rxgk security class (GSSAPI) rxrpc: rxgk: Implement connection rekeying crypto/Kconfig | 1 + crypto/Makefile | 2 + crypto/aead.c | 2 + crypto/krb5/Kconfig | 24 + crypto/krb5/Makefile | 17 + crypto/krb5/internal.h | 162 ++++ crypto/krb5/kdf.c | 334 ++++++++ crypto/krb5/krb5_aead.c | 462 +++++++++++ crypto/krb5/rfc3961_simplified.c | 815 +++++++++++++++++++ crypto/krb5/rfc6803_camellia.c | 190 +++++ crypto/krb5/rfc8009_aes2.c | 394 ++++++++++ crypto/krb5/selftest.c | 533 +++++++++++++ crypto/krb5/selftest_data.c | 370 +++++++++ crypto/testmgr.c | 24 + crypto/testmgr.h | 456 +++++++++++ fs/afs/misc.c | 13 + include/crypto/aead.h | 2 + include/crypto/krb5.h | 147 ++++ include/keys/rxrpc-type.h | 17 + include/trace/events/rxrpc.h | 36 + include/uapi/linux/rxrpc.h | 17 + net/rxrpc/Kconfig | 10 + net/rxrpc/Makefile | 5 +- net/rxrpc/ar-internal.h | 22 + net/rxrpc/conn_event.c | 2 +- net/rxrpc/conn_object.c | 1 + net/rxrpc/key.c | 183 +++++ net/rxrpc/output.c | 2 +- net/rxrpc/protocol.h | 20 + net/rxrpc/rxgk.c | 1244 ++++++++++++++++++++++++++++++ net/rxrpc/rxgk_app.c | 318 ++++++++ net/rxrpc/rxgk_common.h | 58 ++ net/rxrpc/rxgk_kdf.c | 260 +++++++ net/rxrpc/rxkad.c | 6 +- net/rxrpc/security.c | 3 + 35 files changed, 6147 insertions(+), 5 deletions(-) create mode 100644 crypto/krb5/Kconfig create mode 100644 crypto/krb5/Makefile create mode 100644 crypto/krb5/internal.h create mode 100644 crypto/krb5/kdf.c create mode 100644 crypto/krb5/krb5_aead.c create mode 100644 crypto/krb5/rfc3961_simplified.c create mode 100644 crypto/krb5/rfc6803_camellia.c create mode 100644 crypto/krb5/rfc8009_aes2.c create mode 100644 crypto/krb5/selftest.c create mode 100644 crypto/krb5/selftest_data.c create mode 100644 include/crypto/krb5.h create mode 100644 net/rxrpc/rxgk.c create mode 100644 net/rxrpc/rxgk_app.c create mode 100644 net/rxrpc/rxgk_common.h create mode 100644 net/rxrpc/rxgk_kdf.c