Skip to content

Commit 4c782bf

Browse files
committed
add support for md5 checksum validation
1 parent a0be9e4 commit 4c782bf

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
lines changed

runtime/runtime-core/api/runtime-core.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,7 @@ public final class aws/smithy/kotlin/runtime/hashing/Md5 : aws/smithy/kotlin/run
725725
public fun <init> ()V
726726
public fun digest ()[B
727727
public fun reset ()V
728+
public final fun update (B)V
728729
public fun update ([BII)V
729730
}
730731

runtime/runtime-core/common/src/aws/smithy/kotlin/runtime/config/EnvironmentSetting.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,22 @@ public inline fun <reified T : Enum<T>> enumEnvSetting(sysProp: String, envVar:
6868
}
6969
return EnvironmentSetting(parse, sysProp, envVar)
7070
}
71+
72+
@InternalApi
73+
public inline fun <reified T : Enum<T>> enumSetEnvSetting(sysProp: String, envVar: String): EnvironmentSetting<Set<T>?> {
74+
val parse = { strValue: String ->
75+
strValue.split(",")
76+
.map { it.trim() }
77+
.filter { it.isNotEmpty() }
78+
.map { enumValue ->
79+
enumValues<T>()
80+
.firstOrNull { it.name.equals(enumValue, ignoreCase = true) }
81+
?: throw ClientException(
82+
"Value $enumValue is not supported, should be one of ${enumValues<T>().joinToString(", ")}"
83+
)
84+
}
85+
.toSet()
86+
.takeIf { it.isNotEmpty() }
87+
}
88+
return EnvironmentSetting(parse, sysProp, envVar)
89+
}

runtime/runtime-core/common/src/aws/smithy/kotlin/runtime/hashing/Md5.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public abstract class Md5Base : HashFunction {
1818
@InternalApi
1919
public expect class Md5() : Md5Base {
2020
override fun update(input: ByteArray, offset: Int, length: Int)
21+
public fun update(input: Byte)
2122
override fun digest(): ByteArray
2223
override fun reset()
2324
override val blockSizeBytes: Int

runtime/runtime-core/jvm/src/aws/smithy/kotlin/runtime/hashing/Md5JVM.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import java.security.MessageDigest
1111
public actual class Md5 : Md5Base() {
1212
private val md = MessageDigest.getInstance("MD5")
1313
actual override fun update(input: ByteArray, offset: Int, length: Int): Unit = md.update(input, offset, length)
14+
public actual fun update(input: Byte): Unit = md.update(input)
1415
actual override fun digest(): ByteArray = md.digest()
1516
actual override fun reset(): Unit = md.reset()
1617
}

runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/hashing/Md5Native.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ public actual class Md5 actual constructor() : Md5Base() {
1515
TODO("Not yet implemented")
1616
}
1717

18+
public actual fun update(input: Byte) {
19+
TODO("Not yet implemented")
20+
}
21+
1822
actual override fun digest(): ByteArray {
1923
TODO("Not yet implemented")
2024
}

0 commit comments

Comments
 (0)