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

Commit 9cd3e43d authored by Dmitry Dementyev's avatar Dmitry Dementyev Committed by Android (Google) Code Review
Browse files

Merge "Add NonNull annotation to more parameters in Recovery Controller." into pi-dev

parents 603b911e fd4ae0b2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -61,8 +61,8 @@ class BackwardsCompat {
    static android.security.keystore.recovery.KeyDerivationParams fromLegacyKeyDerivationParams(
            KeyDerivationParams keyDerivationParams
    ) {
        return new android.security.keystore.recovery.KeyDerivationParams(
                keyDerivationParams.getAlgorithm(), keyDerivationParams.getSalt());
        return android.security.keystore.recovery.KeyDerivationParams.createSha256Params(
                keyDerivationParams.getSalt());
    }

    static android.security.keystore.recovery.WrappedApplicationKey fromLegacyWrappedApplicationKey(
+3 −3
Original line number Diff line number Diff line
@@ -84,8 +84,8 @@ public final class KeyChainSnapshot implements Parcelable {
    }

    /**
     * Snapshot version for given account. It is incremented when user secret or list of application
     * keys changes.
     * Snapshot version for given recovery agent. It is incremented when user secret or list of
     * application keys changes.
     */
    public int getSnapshotVersion() {
        return mSnapshotVersion;
@@ -178,7 +178,7 @@ public final class KeyChainSnapshot implements Parcelable {
        private KeyChainSnapshot mInstance = new KeyChainSnapshot();

        /**
         * Snapshot version for given account.
         * Snapshot version for the recovery agent.
         *
         * @param snapshotVersion The snapshot version
         * @return This builder.
+3 −5
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;


import com.android.internal.util.Preconditions;

import java.lang.annotation.Retention;
@@ -63,7 +62,7 @@ public final class KeyDerivationParams implements Parcelable {
     * salt + key_material_len + key_material, where salt_len and key_material_len are one-byte, and
     * denote the number of bytes for salt and key_material, respectively.
     */
    public static KeyDerivationParams createSha256Params(@NonNull byte[] salt) {
    public static @NonNull KeyDerivationParams createSha256Params(@NonNull byte[] salt) {
        return new KeyDerivationParams(ALGORITHM_SHA256, salt);
    }

@@ -76,7 +75,7 @@ public final class KeyDerivationParams implements Parcelable {
     * the parallelization parameter p is 1, the block size parameter r is 8, and the hashing output
     * length is 32-byte.
     */
    public static KeyDerivationParams createScryptParams(
    public static @NonNull KeyDerivationParams createScryptParams(
            @NonNull byte[] salt, int memoryDifficulty) {
        return new KeyDerivationParams(ALGORITHM_SCRYPT, salt, memoryDifficulty);
    }
@@ -84,8 +83,7 @@ public final class KeyDerivationParams implements Parcelable {
    /**
     * @hide
     */
    // TODO: Make private once legacy API is removed
    public KeyDerivationParams(@KeyDerivationAlgorithm int algorithm, @NonNull byte[] salt) {
    private KeyDerivationParams(@KeyDerivationAlgorithm int algorithm, @NonNull byte[] salt) {
        this(algorithm, salt, /*memoryDifficulty=*/ -1);
    }

+2 −2
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ public final class RecoveryCertPath implements Parcelable {
     * @param certPath The certificate path to be wrapped.
     * @throws CertificateException if the given certificate path cannot be encoded properly.
     */
    public static RecoveryCertPath createRecoveryCertPath(@NonNull CertPath certPath)
    public static @NonNull RecoveryCertPath createRecoveryCertPath(@NonNull CertPath certPath)
            throws CertificateException {
        // Perform the encoding here to avoid throwing exceptions in writeToParcel
        try {
@@ -61,7 +61,7 @@ public final class RecoveryCertPath implements Parcelable {
     * @return the wrapped certificate path.
     * @throws CertificateException if the wrapped certificate path cannot be decoded properly.
     */
    public CertPath getCertPath() throws CertificateException {
    public @NonNull CertPath getCertPath() throws CertificateException {
        // Perform the decoding here to avoid throwing exceptions in createFromParcel
        return decodeCertPath(mEncodedCertPath);
    }
+2 −2
Original line number Diff line number Diff line
@@ -234,7 +234,7 @@ public class RecoverySession implements AutoCloseable {
     * @throws InternalRecoveryServiceException if an error occurs internal to the recovery service.
     */
    @RequiresPermission(Manifest.permission.RECOVER_KEYSTORE)
    public Map<String, Key> recoverKeyChainSnapshot(
    @NonNull public Map<String, Key> recoverKeyChainSnapshot(
            @NonNull byte[] recoveryKeyBlob,
            @NonNull List<WrappedApplicationKey> applicationKeys
    ) throws SessionExpiredException, DecryptionFailedException, InternalRecoveryServiceException {
@@ -257,7 +257,7 @@ public class RecoverySession implements AutoCloseable {
    }

    /** Given a map from alias to grant alias, returns a map from alias to a {@link Key} handle. */
    private Map<String, Key> getKeysFromGrants(Map<String, String> grantAliases)
    private @NonNull Map<String, Key> getKeysFromGrants(Map<String, String> grantAliases)
            throws InternalRecoveryServiceException {
        ArrayMap<String, Key> keysByAlias = new ArrayMap<>(grantAliases.size());
        for (String alias : grantAliases.keySet()) {
Loading