Skip to content

Commit ba34f76

Browse files
authored
refactor!: separate hashing functions into new subproject (#593)
1 parent 43486ea commit ba34f76

File tree

12 files changed

+27
-19
lines changed

12 files changed

+27
-19
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"id": "d08e52ab-010f-42f0-b4b5-e63bd3890da2",
3+
"type": "misc",
4+
"description": "Refactor hashing functions into new subproject"
5+
}

aws-runtime/aws-config/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ kotlin {
2222
dependencies {
2323
api(project(":aws-runtime:aws-core"))
2424
implementation("aws.smithy.kotlin:logging:$smithyKotlinVersion")
25+
implementation("aws.smithy.kotlin:hashing:$smithyKotlinVersion")
2526
implementation("aws.smithy.kotlin:http:$smithyKotlinVersion")
2627
implementation("aws.smithy.kotlin:utils:$smithyKotlinVersion")
2728
implementation("aws.smithy.kotlin:http-client-engine-default:$smithyKotlinVersion")

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/SsoCredentialsProvider.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import aws.sdk.kotlin.runtime.auth.credentials.internal.sso.SsoClient
1010
import aws.sdk.kotlin.runtime.config.profile.normalizePath
1111
import aws.smithy.kotlin.runtime.auth.awscredentials.Credentials
1212
import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProvider
13+
import aws.smithy.kotlin.runtime.hashing.sha1
1314
import aws.smithy.kotlin.runtime.http.engine.HttpClientEngine
1415
import aws.smithy.kotlin.runtime.serde.json.*
1516
import aws.smithy.kotlin.runtime.time.Clock

aws-runtime/protocols/aws-event-stream/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ kotlin {
1414
commonMain {
1515
dependencies {
1616
api(project(":aws-runtime:aws-core"))
17+
implementation("aws.smithy.kotlin:hashing:$smithyKotlinVersion")
1718
// exposes Buffer/MutableBuffer and SdkByteReadChannel
1819
api("aws.smithy.kotlin:io:$smithyKotlinVersion")
1920
// exposes Flow<T>

aws-runtime/protocols/aws-event-stream/common/src/aws/sdk/kotlin/runtime/protocol/eventstream/Message.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
package aws.sdk.kotlin.runtime.protocol.eventstream
77

88
import aws.sdk.kotlin.runtime.InternalSdkApi
9+
import aws.smithy.kotlin.runtime.hashing.crc32
910
import aws.smithy.kotlin.runtime.io.*
10-
import aws.smithy.kotlin.runtime.util.crc32
1111

1212
internal const val MESSAGE_CRC_BYTE_LEN = 4
1313

aws-runtime/protocols/aws-event-stream/common/src/aws/sdk/kotlin/runtime/protocol/eventstream/Prelude.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
package aws.sdk.kotlin.runtime.protocol.eventstream
77

88
import aws.sdk.kotlin.runtime.InternalSdkApi
9+
import aws.smithy.kotlin.runtime.hashing.crc32
910
import aws.smithy.kotlin.runtime.io.*
10-
import aws.smithy.kotlin.runtime.util.crc32
1111

1212
internal const val PRELUDE_BYTE_LEN = 8
1313
internal const val PRELUDE_BYTE_LEN_WITH_CRC = PRELUDE_BYTE_LEN + 4
@@ -36,7 +36,7 @@ public data class Prelude(val totalLen: Int, val headersLength: Int) {
3636
preludeBuf.writeInt(headersLength)
3737

3838
dest.writeFully(preludeBuf)
39-
dest.writeInt(bytes.crc32().toInt())
39+
dest.writeUInt(bytes.crc32())
4040
}
4141

4242
public companion object {

aws-runtime/protocols/aws-event-stream/common/test/aws/sdk/kotlin/runtime/protocol/eventstream/EventStreamSigningTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProvider
1010
import aws.smithy.kotlin.runtime.auth.awssigning.AwsSignatureType
1111
import aws.smithy.kotlin.runtime.auth.awssigning.AwsSigningConfig
1212
import aws.smithy.kotlin.runtime.auth.awssigning.crt.CrtAwsSigner
13+
import aws.smithy.kotlin.runtime.hashing.sha256
1314
import aws.smithy.kotlin.runtime.io.SdkByteBuffer
1415
import aws.smithy.kotlin.runtime.io.bytes
1516
import aws.smithy.kotlin.runtime.time.Instant
1617
import aws.smithy.kotlin.runtime.time.ManualClock
1718
import aws.smithy.kotlin.runtime.util.encodeToHex
18-
import aws.smithy.kotlin.runtime.util.sha256
1919
import kotlinx.coroutines.ExperimentalCoroutinesApi
2020
import kotlinx.coroutines.test.runTest
2121
import kotlin.test.Ignore

codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/customization/glacier/GlacierBodyChecksum.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class GlacierBodyChecksum : KotlinIntegration {
4040
}
4141

4242
override fun render(ctx: ProtocolGenerator.GenerationContext, op: OperationShape, writer: KotlinWriter) {
43-
writer.addImport(RuntimeTypes.Utils.Sha256)
43+
writer.addImport(RuntimeTypes.Hashing.Sha256)
4444
val middleware = glacierSymbol("GlacierBodyChecksum")
4545
writer.addImport(middleware)
4646
writer.write("op.install(#T())", middleware)

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ kotlin.native.ignoreDisabledTargets=true
66
org.gradle.jvmargs=-Xmx6g -XX:MaxPermSize=6g -XX:MaxMetaspaceSize=1G
77

88
# sdk
9-
sdkVersion=0.14.5-SNAPSHOT
9+
sdkVersion=0.15.0-SNAPSHOT
1010

1111
# codegen
1212
smithyVersion=1.17.0
1313
smithyGradleVersion=0.5.3
1414
# smithy-kotlin codegen and runtime are versioned together
15-
smithyKotlinVersion=0.8.6-SNAPSHOT
15+
smithyKotlinVersion=0.9.0-SNAPSHOT
1616

1717
# kotlin
1818
kotlinVersion=1.6.10

services/glacier/common/src/aws/sdk/kotlin/services/glacier/internal/GlacierBodyChecksum.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ package aws.sdk.kotlin.services.glacier.internal
77

88
import aws.sdk.kotlin.services.glacier.model.GlacierException
99
import aws.smithy.kotlin.runtime.client.operationName
10+
import aws.smithy.kotlin.runtime.hashing.Sha256
1011
import aws.smithy.kotlin.runtime.http.HttpBody
1112
import aws.smithy.kotlin.runtime.http.operation.ModifyRequestMiddleware
1213
import aws.smithy.kotlin.runtime.http.operation.SdkHttpOperation
1314
import aws.smithy.kotlin.runtime.http.operation.SdkHttpRequest
1415
import aws.smithy.kotlin.runtime.http.request.headers
15-
import aws.smithy.kotlin.runtime.util.Sha256
1616
import aws.smithy.kotlin.runtime.util.encodeToHex
1717

1818
private const val defaultChunkSizeBytes = 1024 * 1024 // 1MB
1919

2020
internal class GlacierBodyChecksum(
21-
private val treeHasher: TreeHasher = TreeHasherImpl(defaultChunkSizeBytes) { Sha256() }
21+
private val treeHasher: TreeHasher = TreeHasherImpl(defaultChunkSizeBytes, ::Sha256)
2222
) : ModifyRequestMiddleware {
2323
override fun install(op: SdkHttpOperation<*, *>) {
2424
op.execution.finalize.register(this)

0 commit comments

Comments
 (0)