Index: sbin/decryptcore/decryptcore.c =================================================================== --- sbin/decryptcore/decryptcore.c +++ sbin/decryptcore/decryptcore.c @@ -204,6 +204,9 @@ case KERNELDUMP_ENC_AES_256_CBC: cipher = EVP_aes_256_cbc(); break; + case KERNELDUMP_ENC_CHACHA20: + cipher = EVP_chacha20(); + break; default: pjdlog_error("Invalid encryption algorithm."); goto failed; Index: sbin/dumpon/dumpon.c =================================================================== --- sbin/dumpon/dumpon.c +++ sbin/dumpon/dumpon.c @@ -253,7 +253,7 @@ if (kdap->kda_encryptedkey == NULL) err(1, "Unable to allocate encrypted key"); - kdap->kda_encryption = KERNELDUMP_ENC_AES_256_CBC; + kdap->kda_encryption = KERNELDUMP_ENC_CHACHA20; arc4random_buf(kdap->kda_key, sizeof(kdap->kda_key)); if (RSA_public_encrypt(sizeof(kdap->kda_key), kdap->kda_key, kdap->kda_encryptedkey, pubkey, Index: sys/kern/kern_shutdown.c =================================================================== --- sys/kern/kern_shutdown.c +++ sys/kern/kern_shutdown.c @@ -77,6 +77,7 @@ #include #include +#include #include #include @@ -172,8 +173,13 @@ struct kerneldumpcrypto { uint8_t kdc_encryption; uint8_t kdc_iv[KERNELDUMP_IV_MAX_SIZE]; + /* XXX Proof of concept */ +#if 0 keyInstance kdc_ki; cipherInstance kdc_ci; +#else + struct chacha_ctx kdc_chacha; +#endif uint32_t kdc_dumpkeysize; struct kerneldumpkey kdc_dumpkey[]; }; @@ -970,10 +976,17 @@ kdc->kdc_encryption = encryption; switch (kdc->kdc_encryption) { + /* XXX Proof of concept */ +#if 0 case KERNELDUMP_ENC_AES_256_CBC: if (rijndael_makeKey(&kdc->kdc_ki, DIR_ENCRYPT, 256, key) <= 0) goto failed; break; +#else + case KERNELDUMP_ENC_CHACHA20: + chacha_keysetup(&kdc->kdc_chacha, key, 256); + break; +#endif default: goto failed; } @@ -1015,6 +1028,8 @@ bcopy(hash, kdc->kdc_iv, sizeof(kdc->kdc_iv)); switch (kdc->kdc_encryption) { + /* XXX Proof of concept */ +#if 0 case KERNELDUMP_ENC_AES_256_CBC: if (rijndael_cipherInit(&kdc->kdc_ci, MODE_CBC, kdc->kdc_iv) <= 0) { @@ -1022,6 +1037,11 @@ goto out; } break; +#else + case KERNELDUMP_ENC_CHACHA20: + chacha_ivsetup(&kdc->kdc_chacha, kdc->kdc_iv, NULL); + break; +#endif default: error = EINVAL; goto out; @@ -1128,6 +1148,7 @@ } if (compression != KERNELDUMP_COMP_NONE) { +#if 0 /* * We currently can't support simultaneous encryption and * compression. @@ -1136,6 +1157,7 @@ error = EOPNOTSUPP; goto cleanup; } +#endif dumper.kdcomp = kerneldumpcomp_create(&dumper, compression); if (dumper.kdcomp == NULL) { error = EINVAL; @@ -1221,6 +1243,8 @@ { switch (kdc->kdc_encryption) { + /* XXX Proof of concept */ +#if 0 case KERNELDUMP_ENC_AES_256_CBC: if (rijndael_blockEncrypt(&kdc->kdc_ci, &kdc->kdc_ki, buf, 8 * size, buf) <= 0) { @@ -1231,6 +1255,11 @@ return (EIO); } break; +#else + case KERNELDUMP_ENC_CHACHA20: + chacha_encrypt_bytes(&kdc->kdc_chacha, buf, buf, size); + break; +#endif default: return (EINVAL); } Index: sys/sys/kerneldump.h =================================================================== --- sys/sys/kerneldump.h +++ sys/sys/kerneldump.h @@ -63,6 +63,7 @@ #define KERNELDUMP_ENC_NONE 0 #define KERNELDUMP_ENC_AES_256_CBC 1 +#define KERNELDUMP_ENC_CHACHA20 2 #define KERNELDUMP_BUFFER_SIZE 4096 #define KERNELDUMP_IV_MAX_SIZE 32