This repository was archived by the owner on Jul 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoteKeyPair.java
More file actions
53 lines (42 loc) · 1.76 KB
/
RemoteKeyPair.java
File metadata and controls
53 lines (42 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package org.biscuitsec.biscuit.crypto;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.SignatureException;
import java.util.Optional;
public class RemoteKeyPair extends KeyPair {
private final org.biscuitsec.biscuit.crypto.PublicKey publicKey;
private final Signer signer;
public RemoteKeyPair(org.biscuitsec.biscuit.crypto.PublicKey publicKey, Signer signer) {
this.publicKey = publicKey;
this.signer = signer;
}
@Override
public byte[] toBytes() {
throw new RuntimeException("Illegal operation; remote private private key cannot be accessed.");
}
@Override
public String toHex() {
throw new RuntimeException("Illegal operation; remote private private key cannot be accessed.");
}
@Override
public PublicKey publicKey() {
return publicKey.key;
}
@Override
public byte[] sign(byte[] block, byte[] publicKey) throws NoSuchAlgorithmException, SignatureException, InvalidKeyException {
return signer.signStandard(block, this.publicKey.algorithm, publicKey);
}
@Override
public byte[] signExternal(byte[] block, byte[] publicKey, byte[] external) throws NoSuchAlgorithmException, SignatureException, InvalidKeyException {
return signer.signExternal(block, this.publicKey.algorithm, publicKey, external);
}
@Override
public byte[] signSealed(byte[] block, byte[] publicKey, byte[] seal) throws NoSuchAlgorithmException, SignatureException, InvalidKeyException {
return signer.signSealed(block, this.publicKey.algorithm, publicKey, seal);
}
@Override
public org.biscuitsec.biscuit.crypto.PublicKey public_key() {
return publicKey;
}
}