Search in sources :

Example 6 with FileStreamSignature

use of com.hedera.mirror.importer.domain.FileStreamSignature in project hedera-mirror-node by hashgraph.

the class NodeSignatureVerifierTest method testNoFileHashSignature.

@Test
void testNoFileHashSignature() throws GeneralSecurityException {
    byte[] fileHash = TestUtils.generateRandomByteArray(48);
    FileStreamSignature fileStreamSignature = buildFileStreamSignature(fileHash, null, null, null);
    List<FileStreamSignature> fileStreamSignatures = Arrays.asList(fileStreamSignature);
    Exception e = assertThrows(SignatureVerificationException.class, () -> nodeSignatureVerifier.verify(fileStreamSignatures));
    assertTrue(e.getMessage().contains("Signature verification failed for file"));
}
Also used : FileStreamSignature(com.hedera.mirror.importer.domain.FileStreamSignature) GeneralSecurityException(java.security.GeneralSecurityException) SignatureVerificationException(com.hedera.mirror.importer.exception.SignatureVerificationException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Test(org.junit.jupiter.api.Test)

Example 7 with FileStreamSignature

use of com.hedera.mirror.importer.domain.FileStreamSignature in project hedera-mirror-node by hashgraph.

the class NodeSignatureVerifierTest method buildBareBonesFileStreamSignature.

private FileStreamSignature buildBareBonesFileStreamSignature() {
    FileStreamSignature fileStreamSignature = new FileStreamSignature();
    fileStreamSignature.setFilename("");
    fileStreamSignature.setNodeAccountId(nodeId);
    fileStreamSignature.setSignatureType(SignatureType.SHA_384_WITH_RSA);
    fileStreamSignature.setStreamType(StreamType.RECORD);
    return fileStreamSignature;
}
Also used : FileStreamSignature(com.hedera.mirror.importer.domain.FileStreamSignature)

Example 8 with FileStreamSignature

use of com.hedera.mirror.importer.domain.FileStreamSignature in project hedera-mirror-node by hashgraph.

the class NodeSignatureVerifierTest method testNoSignatureType.

@Test
void testNoSignatureType() throws GeneralSecurityException {
    byte[] fileHash = TestUtils.generateRandomByteArray(48);
    FileStreamSignature fileStreamSignature = buildFileStreamSignature(fileHash, signHash(fileHash), null, null);
    fileStreamSignature.setSignatureType(null);
    List<FileStreamSignature> fileStreamSignatures = Arrays.asList(fileStreamSignature);
    Exception e = assertThrows(SignatureVerificationException.class, () -> nodeSignatureVerifier.verify(fileStreamSignatures));
    assertTrue(e.getMessage().contains("Signature verification failed for file"));
}
Also used : FileStreamSignature(com.hedera.mirror.importer.domain.FileStreamSignature) GeneralSecurityException(java.security.GeneralSecurityException) SignatureVerificationException(com.hedera.mirror.importer.exception.SignatureVerificationException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Test(org.junit.jupiter.api.Test)

Example 9 with FileStreamSignature

use of com.hedera.mirror.importer.domain.FileStreamSignature in project hedera-mirror-node by hashgraph.

the class NodeSignatureVerifierTest method testV5FileStreamSignature.

@Test
void testV5FileStreamSignature() throws GeneralSecurityException {
    byte[] fileHash = TestUtils.generateRandomByteArray(48);
    byte[] metadataHash = TestUtils.generateRandomByteArray(48);
    FileStreamSignature fileStreamSignature = buildFileStreamSignature(fileHash, signHash(fileHash), metadataHash, signHash(metadataHash));
    nodeSignatureVerifier.verify(Arrays.asList(fileStreamSignature));
}
Also used : FileStreamSignature(com.hedera.mirror.importer.domain.FileStreamSignature) Test(org.junit.jupiter.api.Test)

Example 10 with FileStreamSignature

use of com.hedera.mirror.importer.domain.FileStreamSignature in project hedera-mirror-node by hashgraph.

the class NodeSignatureVerifierTest method testNoFileHash.

@Test
void testNoFileHash() throws GeneralSecurityException {
    byte[] fileHash = TestUtils.generateRandomByteArray(48);
    FileStreamSignature fileStreamSignature = buildFileStreamSignature(null, signHash(fileHash), null, null);
    List<FileStreamSignature> fileStreamSignatures = Arrays.asList(fileStreamSignature);
    Exception e = assertThrows(SignatureVerificationException.class, () -> nodeSignatureVerifier.verify(fileStreamSignatures));
    assertTrue(e.getMessage().contains("Signature verification failed for file"));
}
Also used : FileStreamSignature(com.hedera.mirror.importer.domain.FileStreamSignature) GeneralSecurityException(java.security.GeneralSecurityException) SignatureVerificationException(com.hedera.mirror.importer.exception.SignatureVerificationException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Test(org.junit.jupiter.api.Test)

Aggregations

FileStreamSignature (com.hedera.mirror.importer.domain.FileStreamSignature)24 Test (org.junit.jupiter.api.Test)14 SignatureVerificationException (com.hedera.mirror.importer.exception.SignatureVerificationException)12 GeneralSecurityException (java.security.GeneralSecurityException)7 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)7 PublicKey (java.security.PublicKey)7 StreamFileData (com.hedera.mirror.importer.domain.StreamFileData)5 EntityId (com.hedera.mirror.common.domain.entity.EntityId)4 InvalidStreamFileException (com.hedera.mirror.importer.exception.InvalidStreamFileException)4 HashMap (java.util.HashMap)4 AddressBook (com.hedera.mirror.common.domain.addressbook.AddressBook)3 StreamFilename (com.hedera.mirror.importer.domain.StreamFilename)3 Stopwatch (com.google.common.base.Stopwatch)2 Multimap (com.google.common.collect.Multimap)2 StreamType (com.hedera.mirror.common.domain.StreamType)2 AddressBookService (com.hedera.mirror.importer.addressbook.AddressBookService)2 HashMismatchException (com.hedera.mirror.importer.exception.HashMismatchException)2 SignatureFileParsingException (com.hedera.mirror.importer.exception.SignatureFileParsingException)2 ValidatedDataInputStream (com.hedera.mirror.importer.reader.ValidatedDataInputStream)2 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)2