Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f00e02cb authored by Eric Biggers's avatar Eric Biggers
Browse files

Zeroize the vendor auth secret encryption key

Secrets derived from or unlocked by the LSKF need to be zeroized as soon
as they are no longer needed.

Bug: 320392352
Test: atest FrameworksServicesTests:com.android.server.locksettings
Flag: EXEMPT bugfix
Change-Id: I76f70b4df6f8bbee0018fb6ee6ab7d9c56fe9065
parent 8a539420
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -2072,11 +2072,15 @@ class SyntheticPasswordManager {
            @NonNull final byte[] vendorAuthSecret,
            @NonNull final SyntheticPassword sp,
            @UserIdInt final int userId) {
        final byte[] encrypted =
                SyntheticPasswordCrypto.encrypt(
                        sp.deriveVendorAuthSecretEncryptionKey(), new byte[0], vendorAuthSecret);
        final byte[] key = sp.deriveVendorAuthSecretEncryptionKey();
        try {
            final byte[] encrypted = SyntheticPasswordCrypto.encrypt(key, new byte[0],
                    vendorAuthSecret);
            saveState(VENDOR_AUTH_SECRET_NAME, encrypted, NULL_PROTECTOR_ID, userId);
            syncState(userId);
        } finally {
            ArrayUtils.zeroize(key);
        }
    }

    public @Nullable byte[] readVendorAuthSecret(
@@ -2085,7 +2089,11 @@ class SyntheticPasswordManager {
        if (encrypted == null) {
            return null;
        }
        return SyntheticPasswordCrypto.decrypt(
                sp.deriveVendorAuthSecretEncryptionKey(), new byte[0], encrypted);
        final byte[] key = sp.deriveVendorAuthSecretEncryptionKey();
        try {
            return SyntheticPasswordCrypto.decrypt(key, new byte[0], encrypted);
        } finally {
            ArrayUtils.zeroize(key);
        }
    }
}