Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/com/google/cose/OkpKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.google.cose.exceptions.CoseException;
import com.google.cose.utils.CborUtils;
import com.google.cose.utils.Headers;
import java.math.BigInteger;
import java.util.Arrays;

/**
Expand Down Expand Up @@ -41,6 +42,15 @@ public byte[] getPublicKeyBytes() {
return Arrays.copyOf(publicKeyBytes, publicKeyBytes.length);
}

public BigInteger getPublicKeyBytesAsBigInteger() {
// Reverse the bytes to get the correct big-endian representation.
byte[] reversedBytes = new byte[publicKeyBytes.length];
for (int i = 0; i < publicKeyBytes.length; i++) {
reversedBytes[i] = publicKeyBytes[publicKeyBytes.length - 1 - i];
}
return new BigInteger(1, reversedBytes);
}

/** Recursive builder to build out the Ec2 key and its subclasses. */
abstract static class Builder<T extends Builder<T>> extends CoseKey.Builder<T> {
private Integer curve = null;
Expand Down