forked from hyperledger/fabric-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warning1: This branch must be run with the fabric pull-request branch on hyperledger/fabric#3343 Warning2: The java gateway does not support ed25519 TLS certificates. This will lead to either warning users that java-gateway cannot communicate to ed25519 peers/orderers with TLS certificates OR the pull request on hyperledger/fabric#3343 fabric should disable ed25519 TLS certificates. Signed-off-by: Johann Westphall <johannwestphall@gmail.com>
- Loading branch information
Showing
22 changed files
with
268 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
java/src/main/java/org/hyperledger/fabric/client/identity/ED25519Signer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2020 IBM All Rights Reserved. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.hyperledger.fabric.client.identity; | ||
|
||
import java.security.GeneralSecurityException; | ||
import java.security.Provider; | ||
import java.security.Signature; | ||
|
||
import org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey; | ||
import org.bouncycastle.jce.provider.BouncyCastleProvider; | ||
|
||
final class ED25519Signer implements Signer { | ||
|
||
private static final Provider PROVIDER = new BouncyCastleProvider(); | ||
private static final String ALGORITHM_NAME = "Ed25519"; | ||
|
||
private final EdDSAPrivateKey privateKey; | ||
|
||
ED25519Signer(final EdDSAPrivateKey privateKey) { | ||
this.privateKey = privateKey; | ||
} | ||
|
||
@Override | ||
public byte[] sign(final byte[] message) throws GeneralSecurityException { | ||
byte[] rawSignature = generateSignature(message); | ||
return rawSignature; | ||
} | ||
|
||
private byte[] generateSignature(final byte[] message) throws GeneralSecurityException { | ||
Signature signer = Signature.getInstance(ALGORITHM_NAME, PROVIDER); | ||
signer.initSign(privateKey); | ||
signer.update(message); | ||
return signer.sign(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.