Skip to content

Conversation

@jrandallclark
Copy link

Adds support for AES encrypted private keys exported by ndn-cxx.

Copy link
Member

@Pesa Pesa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit message title is misleading. It sounds like you're adding support for decrypting AES (symmetric) keys. This is about decryption of AES-encrypted private keys (of an asymmetric key pair). Please rephrase it.

public class TpmPrivateKey {
static {
Security.insertProviderAt(new org.spongycastle.jce.provider.BouncyCastleProvider(), 1);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a newline after this


if (key == null)
return new Blob();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't add this newline

Comment on lines 158 to 161
byte[] encodingBytes = new byte[10];
encodingBytes = new byte[encoding.remaining()];
encoding.get(encodingBytes, 0, encodingBytes.length);
encoding.clear();
encodingBytes = new byte[encoding.capacity()];
encoding.get(encodingBytes, 0, encodingBytes.length);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not following this code, why do you need to do all this? encodingBytes is allocated 3 times?

* This replaces any existing private key in this object.
* @param encoding The byte buffer with the private key encoding.
* @param password The password for decrypting the private key, which should
* have characters in the range of 1 to 127.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does this limitation come from?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's leftover from the code I replaced. I'll remove it.

} catch (IOException | OperatorCreationException | PKCSException ex) {
throw new TpmPrivateKey.Error
("loadEncryptedPkcs8: Error parsing PrivateKey info: " + ex);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong indentation

try {
SafeBag safebag = new SafeBag(testKey);
fixture_.keyChain_.importSafeBag(safebag, password.buf());
} catch (Throwable ex) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong indentation

@jrandallclark jrandallclark changed the title Add AES Private Key decryption Add decryption of AES-encrypted private keys Dec 6, 2019
@Pesa
Copy link
Member

Pesa commented Dec 31, 2019

You should squash the two commits together and force-push to the branch in order to properly update the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants