Skip to content

Commit

Permalink
Correct non-reset push
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Crawford <[email protected]>
  • Loading branch information
stephen-crawford committed Oct 11, 2022
1 parent 06ff2e4 commit 46717dd
Showing 1 changed file with 0 additions and 32 deletions.
32 changes: 0 additions & 32 deletions server/src/main/java/org/opensearch/identity/Principals.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package org.opensearch.identity;

import java.security.NoSuchAlgorithmException;
import java.security.Principal;

/**
Expand All @@ -21,42 +20,11 @@ public enum Principals {
UNAUTHENTICATED(new StringPrincipal("Unauthenticated"));

private final Principal principal;
private final SecretKey secretKey;
private final byte[] initializationVector;
public static final String ALGORITHM = "AES";
public static final int KEY_SIZE = 128;
public static final int INITIALIZATION_VECTOR_SIZE = 96;
public static final int TAG_LENGTH = 128;

private Principals(final Principal principal) {
this.principal = principal;
this.initializationVector = generateIV();
try{
this.secretKey = generateSecretKey();
}
catch (NoSuchAlgorithmException noAlgo) {
throw new Error(noAlgo);

}
}


public static byte[] generateIV(int ivLength){

byte[] nonce = new byte[ivLength/8];
SecureRandom secureRandom = new SecureRandom();
secureRandom.nextBytes(nonce);
return nonce;
}

public static SecretKey generateSecretKey(int keyLength) throws NoSuchAlgorithmException {

KeyGenerator keyGen = KeyGenerator.getInstance(ALGORITHM);
keyGen.init(keyLength);
return keyGen.generateKey();
}


/**
* Returns the underlying principal for this
*/
Expand Down

0 comments on commit 46717dd

Please sign in to comment.