From 412cff60f59517e0336b09bf1910f8adb2e7efb2 Mon Sep 17 00:00:00 2001 From: Colin O'Brien Date: Wed, 26 Jun 2024 14:49:26 +1200 Subject: [PATCH] post rebase fixup still some tests unhappy --- .../biscuit/token/ThirdPartyBlockRequest.java | 11 +---------- .../biscuitsec/biscuit/token/UnverifiedBiscuit.java | 4 ++-- .../org/biscuitsec/biscuit/token/builder/Biscuit.java | 4 ---- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/biscuitsec/biscuit/token/ThirdPartyBlockRequest.java b/src/main/java/org/biscuitsec/biscuit/token/ThirdPartyBlockRequest.java index 510f62c..00b1831 100644 --- a/src/main/java/org/biscuitsec/biscuit/token/ThirdPartyBlockRequest.java +++ b/src/main/java/org/biscuitsec/biscuit/token/ThirdPartyBlockRequest.java @@ -45,16 +45,7 @@ public Either createBlock(KeyPair ke byte[] serializedBlock = res.get(); - Signature sgr = KeyPair.generateSignature(keyPair.public_key().algorithm); - sgr.initSign(keyPair.private_key()); - sgr.update(serializedBlock); - - ByteBuffer algo_buf = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN); - algo_buf.putInt(Integer.valueOf(Schema.PublicKey.Algorithm.Ed25519.getNumber())); - algo_buf.flip(); - sgr.update(algo_buf); - sgr.update(previousKey.toBytes()); - byte[] signature = sgr.sign(); + byte[] signature = keyPair.sign(serializedBlock, previousKey.toBytes()); PublicKey publicKey = keyPair.public_key(); diff --git a/src/main/java/org/biscuitsec/biscuit/token/UnverifiedBiscuit.java b/src/main/java/org/biscuitsec/biscuit/token/UnverifiedBiscuit.java index e1b8d3c..9317b9b 100644 --- a/src/main/java/org/biscuitsec/biscuit/token/UnverifiedBiscuit.java +++ b/src/main/java/org/biscuitsec/biscuit/token/UnverifiedBiscuit.java @@ -256,14 +256,14 @@ public ThirdPartyBlockRequest thirdPartyRequest() { */ public UnverifiedBiscuit appendThirdPartyBlock(PublicKey externalKey, ThirdPartyBlockContents blockResponse) throws NoSuchAlgorithmException, SignatureException, InvalidKeyException, Error { - KeyPair nextKeyPair = KeyPair.generate(Schema.PublicKey.Algorithm.Ed25519); + KeyPair nextKeyPair = KeyPair.generate(externalKey.algorithm); Signature sgr = KeyPair.generateSignature(externalKey.algorithm); sgr.initVerify(externalKey.key); sgr.update(blockResponse.payload); ByteBuffer algo_buf = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN); - algo_buf.putInt(Integer.valueOf(Schema.PublicKey.Algorithm.Ed25519.getNumber())); + algo_buf.putInt(Integer.valueOf(externalKey.algorithm.getNumber())); algo_buf.flip(); sgr.update(algo_buf); diff --git a/src/main/java/org/biscuitsec/biscuit/token/builder/Biscuit.java b/src/main/java/org/biscuitsec/biscuit/token/builder/Biscuit.java index 27e9313..db21a76 100644 --- a/src/main/java/org/biscuitsec/biscuit/token/builder/Biscuit.java +++ b/src/main/java/org/biscuitsec/biscuit/token/builder/Biscuit.java @@ -2,12 +2,8 @@ import org.biscuitsec.biscuit.crypto.KeyPair; import org.biscuitsec.biscuit.crypto.PublicKey; -import org.biscuitsec.biscuit.crypto.Signer; import org.biscuitsec.biscuit.datalog.SchemaVersion; import org.biscuitsec.biscuit.datalog.SymbolTable; -import org.biscuitsec.biscuit.datalog.Check; -import org.biscuitsec.biscuit.datalog.Fact; -import org.biscuitsec.biscuit.datalog.Rule; import org.biscuitsec.biscuit.error.Error; import org.biscuitsec.biscuit.token.Block; import io.vavr.Tuple2;