Skip to content

Commit

Permalink
Resolve a couple TODOs by being pleasantly surprised that the underly…
Browse files Browse the repository at this point in the history
…ing hack is actually valid
  • Loading branch information
jchambers committed Mar 3, 2024
1 parent a8910ae commit 585690e
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public byte[] generateSecret(final PrivateKey privateKey, final PublicKey public

@Override
public byte[] serializePublicKey(final PublicKey publicKey) {
// TODO This is a pretty hacky way of dealing with key serialization; come back to this with a real encoder
// This is a little hacky, but the structure for an X.509 public key defines the order in which its elements appear.
// The first part of the key, which defines the algorithm and its parameters, is always the same for keys of the
// same type, and the last N bytes are the literal key material.
final byte[] serializedPublicKey = new byte[getPublicKeyLength()];
System.arraycopy(publicKey.getEncoded(), getX509Prefix().length, serializedPublicKey, 0, getPublicKeyLength());

Expand All @@ -51,7 +53,6 @@ public byte[] serializePublicKey(final PublicKey publicKey) {

@Override
public PublicKey deserializePublicKey(final byte[] publicKeyBytes) {
// TODO This is a pretty hacky way of dealing with key deserialization; come back to this with a real decoder
final int publicKeyLength = getPublicKeyLength();

if (publicKeyBytes.length != publicKeyLength) {
Expand Down

0 comments on commit 585690e

Please sign in to comment.