-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- update embedded tuf roots to newer roots - move key parsing into tuf package - have separate tuf signature verifiers - remove copy of prod data - have all ed25519 key handling done by bc Signed-off-by: Appu Goundan <appu@google.com>
- Loading branch information
1 parent
764abc9
commit 51b41f7
Showing
65 changed files
with
813 additions
and
2,912 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
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
41 changes: 41 additions & 0 deletions
41
sigstore-java/src/main/java/dev/sigstore/tuf/encryption/EcdsaVerifier.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,41 @@ | ||
/* | ||
* Copyright 2022 The Sigstore Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package dev.sigstore.tuf.encryption; | ||
|
||
import java.security.InvalidKeyException; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.PublicKey; | ||
import java.security.Signature; | ||
import java.security.SignatureException; | ||
|
||
/** ECDSA verifier, instantiated in {@link Verifiers}. */ | ||
class EcdsaVerifier implements Verifier { | ||
|
||
private final PublicKey publicKey; | ||
|
||
EcdsaVerifier(PublicKey publicKey) { | ||
this.publicKey = publicKey; | ||
} | ||
|
||
@Override | ||
public boolean verify(byte[] artifact, byte[] signature) | ||
throws NoSuchAlgorithmException, InvalidKeyException, SignatureException { | ||
var verifier = Signature.getInstance("SHA256withECDSA"); | ||
verifier.initVerify(publicKey); | ||
verifier.update(artifact); | ||
return verifier.verify(signature); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
sigstore-java/src/main/java/dev/sigstore/tuf/encryption/Ed25519Verifier.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,42 @@ | ||
/* | ||
* Copyright 2022 The Sigstore Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package dev.sigstore.tuf.encryption; | ||
|
||
import java.security.InvalidKeyException; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.PublicKey; | ||
import java.security.Signature; | ||
import java.security.SignatureException; | ||
|
||
/** Ed25519 verifier, instantiated by {@link Verifiers}. */ | ||
class Ed25519Verifier implements Verifier { | ||
|
||
private final PublicKey publicKey; | ||
|
||
Ed25519Verifier(PublicKey publicKey) { | ||
this.publicKey = publicKey; | ||
} | ||
|
||
/** EdDSA verifiers hash implicitly for ed25519 keys. */ | ||
@Override | ||
public boolean verify(byte[] artifact, byte[] signature) | ||
throws NoSuchAlgorithmException, InvalidKeyException, SignatureException { | ||
var verifier = Signature.getInstance("Ed25519"); | ||
verifier.initVerify(publicKey); | ||
verifier.update(artifact); | ||
return verifier.verify(signature); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
sigstore-java/src/main/java/dev/sigstore/tuf/encryption/RsaPssVerifier.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,41 @@ | ||
/* | ||
* Copyright 2022 The Sigstore Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package dev.sigstore.tuf.encryption; | ||
|
||
import java.security.InvalidKeyException; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.PublicKey; | ||
import java.security.Signature; | ||
import java.security.SignatureException; | ||
|
||
/** RSA verifier using PSS and MGF1, instantiated by {@link Verifiers}. */ | ||
class RsaPssVerifier implements Verifier { | ||
|
||
private final PublicKey publicKey; | ||
|
||
RsaPssVerifier(PublicKey publicKey) { | ||
this.publicKey = publicKey; | ||
} | ||
|
||
@Override | ||
public boolean verify(byte[] artifact, byte[] signature) | ||
throws NoSuchAlgorithmException, InvalidKeyException, SignatureException { | ||
var verifier = Signature.getInstance("SHA256withRSAandMGF1"); | ||
verifier.initVerify(publicKey); | ||
verifier.update(artifact); | ||
return verifier.verify(signature); | ||
} | ||
} |
Oops, something went wrong.