Skip to content

Commit 9b8dd07

Browse files
authored
CORE-7288 Add digest service for flows (#691)
* Adds sandbox digest service (sandbox singleton) to be used in all sandbox types. * Updates name of platform digest service (platform singleton).
1 parent 29fca45 commit 9b8dd07

File tree

4 files changed

+81
-41
lines changed

4 files changed

+81
-41
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package net.corda.v5.application.crypto
2+
3+
import net.corda.v5.base.annotations.DoNotImplement
4+
import net.corda.v5.base.annotations.Suspendable
5+
import net.corda.v5.crypto.DigestAlgorithmName
6+
import net.corda.v5.crypto.SecureHash
7+
import java.io.InputStream
8+
9+
/**
10+
* Provides hashing capabilities to be used in all sandbox types.
11+
*/
12+
@DoNotImplement
13+
interface DigestService {
14+
/**
15+
* Computes the digest of the [ByteArray].
16+
*
17+
* @param bytes The [ByteArray] to hash.
18+
* @param digestName The digest algorithm to be used for hashing.
19+
*/
20+
@Suspendable
21+
fun hash(bytes: ByteArray, digestName: DigestAlgorithmName): SecureHash
22+
23+
/**
24+
* Computes the digest of the [InputStream].
25+
*
26+
* @param inputStream The [InputStream] to hash.
27+
* @param digestName The digest algorithm to be used for hashing.
28+
*/
29+
@Suspendable
30+
fun hash(inputStream : InputStream, digestName: DigestAlgorithmName): SecureHash
31+
32+
/**
33+
* Returns the [DigestAlgorithmName] digest length in bytes.
34+
*
35+
* @param digestName The digest algorithm to get the digest length for.
36+
*/
37+
@Suspendable
38+
fun digestLength(digestName: DigestAlgorithmName): Int
39+
}

cipher-suite/src/main/kotlin/net/corda/v5/cipher/suite/DigestService.kt

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package net.corda.v5.cipher.suite
2+
3+
import net.corda.v5.crypto.DigestAlgorithmName
4+
import net.corda.v5.crypto.SecureHash
5+
import java.io.InputStream
6+
7+
/**
8+
* The platform digest calculation service. Holds a list of supported digest algorithms to be used for hashing.
9+
*/
10+
interface PlatformDigestService {
11+
12+
/**
13+
* Computes the digest of the [ByteArray].
14+
*
15+
* @param bytes The [ByteArray] to hash.
16+
* @param platformDigestName The digest algorithm to be used for hashing, looked up in platform supported digest algorithms.
17+
*
18+
* @throws [IllegalArgumentException] if the digest algorithm is not supported.
19+
*/
20+
fun hash(bytes: ByteArray, platformDigestName: DigestAlgorithmName): SecureHash
21+
22+
/**
23+
* Computes the digest of the [InputStream].
24+
*
25+
* @param inputStream The [InputStream] to hash.
26+
* @param platformDigestName The digest algorithm to be used for hashing, looked up in platform supported digest algorithms.
27+
*
28+
* @throws [IllegalArgumentException] if the digest algorithm is not supported.
29+
*/
30+
fun hash(inputStream : InputStream, platformDigestName: DigestAlgorithmName): SecureHash
31+
32+
/**
33+
* Returns the [DigestAlgorithmName] digest length in bytes.
34+
*
35+
* @param platformDigestName The digest algorithm to get the digest length for, looked up in platform supported
36+
* digest algorithms.
37+
*
38+
* @throws [IllegalArgumentException] if the digest algorithm is not supported.
39+
*/
40+
fun digestLength(platformDigestName: DigestAlgorithmName): Int
41+
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cordaProductVersion = 5.0.0
77
# NOTE: update this each time this module contains a breaking change
88
## NOTE: currently this is a top level revision, so all API versions will line up, but this could be moved to
99
## a per module property in which case module versions can change independently.
10-
cordaApiRevision = 505
10+
cordaApiRevision = 506
1111

1212
# Main
1313
kotlinVersion = 1.7.21

0 commit comments

Comments
 (0)