Skip to content

Commit

Permalink
Whitespace and variable name fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
wmiaw committed Apr 13, 2018
1 parent cb40f2e commit 5965124
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2016-2017 Netflix, Inc. All rights reserved.
* Copyright (c) 2016-2018 Netflix, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,7 +32,6 @@

/**
* <p>ECC asymmetric keys entity authentication factory.</p>
*
*/
public class EccAuthenticationFactory extends EntityAuthenticationFactory {
/**
Expand Down Expand Up @@ -79,29 +78,29 @@ public ICryptoContext getCryptoContext(final MslContext ctx, final EntityAuthent
// Make sure we have the right kind of entity authentication data.
if (!(authdata instanceof EccAuthenticationData))
throw new MslInternalException("Incorrect authentication data type " + authdata.getClass().getName() + ".");
final EccAuthenticationData rad = (EccAuthenticationData)authdata;
final EccAuthenticationData ead = (EccAuthenticationData)authdata;

// Check for revocation.
final String identity = rad.getIdentity();
final String identity = ead.getIdentity();
if (authutils.isEntityRevoked(identity))
throw new MslEntityAuthException(MslError.ENTITY_REVOKED, "ecc" + identity).setEntityAuthenticationData(rad);
throw new MslEntityAuthException(MslError.ENTITY_REVOKED, "ecc" + identity).setEntityAuthenticationData(ead);

// Verify the scheme is permitted.
if (!authutils.isSchemePermitted(identity, getScheme()))
throw new MslEntityAuthException(MslError.INCORRECT_ENTITYAUTH_DATA, "Authentication Scheme for Device Type Not Supported " + identity + ":" + getScheme()).setEntityAuthenticationData(rad);
throw new MslEntityAuthException(MslError.INCORRECT_ENTITYAUTH_DATA, "Authentication Scheme for Device Type Not Supported " + identity + ":" + getScheme()).setEntityAuthenticationData(ead);

// Extract ECC authentication data.
final String pubkeyid = rad.getPublicKeyId();
final String pubkeyid = ead.getPublicKeyId();
final PublicKey publicKey = store.getPublicKey(pubkeyid);
final PrivateKey privateKey = store.getPrivateKey(pubkeyid);

// The local entity must have a private key.
if (pubkeyid.equals(keyPairId) && privateKey == null)
throw new MslEntityAuthException(MslError.ECC_PRIVATEKEY_NOT_FOUND, pubkeyid).setEntityAuthenticationData(rad);
throw new MslEntityAuthException(MslError.ECC_PRIVATEKEY_NOT_FOUND, pubkeyid).setEntityAuthenticationData(ead);

// Remote entities must have a public key.
else if (!pubkeyid.equals(keyPairId) && publicKey == null)
throw new MslEntityAuthException(MslError.ECC_PUBLICKEY_NOT_FOUND, pubkeyid).setEntityAuthenticationData(rad);
throw new MslEntityAuthException(MslError.ECC_PUBLICKEY_NOT_FOUND, pubkeyid).setEntityAuthenticationData(ead);

// Return the crypto context.
return new EccCryptoContext(identity, privateKey, publicKey, Mode.SIGN_VERIFY);
Expand All @@ -112,5 +111,5 @@ else if (!pubkeyid.equals(keyPairId) && publicKey == null)
/** ECC key store. */
private final EccStore store;
/** Authentication utilities. */
final AuthenticationUtils authutils;
private final AuthenticationUtils authutils;
}
7 changes: 3 additions & 4 deletions core/src/main/java/com/netflix/msl/entityauth/EccStore.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Copyright (c) 2016 Netflix, Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand All @@ -21,7 +21,6 @@

/**
* An ECC public key store contains trusted ECC public and private keys.
*
*/
public interface EccStore {
/**
Expand All @@ -36,10 +35,10 @@ public interface EccStore {
* @return the public key of the identified key pair or null if not found.
*/
public PublicKey getPublicKey(final String identity);

/**
* Return the private key of the identified ECC key pair.
*
*
* @param identity ECC key pair identity.
* @return the private key of the identified key pair or null if not found.
*/
Expand Down

0 comments on commit 5965124

Please sign in to comment.