Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use md5 implementation of RustCrypto organization #1404

Merged
merged 2 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,21 @@ author = "alonlud"
references = ["smithy-rs#1390"]
meta = { "breaking" = false, "tada" = true, "bug" = false }
author = "Velfi"

[[smithy-rs]]
message = "Add ability to specify a different rust crate name than the one derived from the package name"
references = ["smithy-rs#1404"]
meta = { "breaking" = false, "tada" = false, "bug" = false }
author = "petrosagg"

[[smithy-rs]]
message = "Switch to [RustCrypto](https://github.com/RustCrypto)'s implementation of MD5."
references = ["smithy-rs#1404"]
meta = { "breaking" = false, "tada" = false, "bug" = false }
author = "petrosagg"

[[aws-sdk-rust]]
message = "Switch to [RustCrypto](https://github.com/RustCrypto)'s implementation of MD5."
references = ["smithy-rs#1404"]
meta = { "breaking" = false, "tada" = false, "bug" = false }
author = "petrosagg"
petrosagg marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ class InlineDependency(
}
}

fun CargoDependency.asType(): RuntimeType =
RuntimeType(null, dependency = this, namespace = this.name.replace("-", "_"))
fun CargoDependency.asType(): RuntimeType = RuntimeType(null, dependency = this, namespace = rustName)

data class Feature(val name: String, val default: Boolean, val deps: List<String>)

Expand All @@ -128,7 +127,8 @@ data class CargoDependency(
private val location: DependencyLocation,
val scope: DependencyScope = DependencyScope.Compile,
val optional: Boolean = false,
val features: Set<String> = emptySet()
val features: Set<String> = emptySet(),
val rustName: String = name.replace("-", "_")
) : RustDependency(name) {
val key: Triple<String, DependencyLocation, DependencyScope> get() = Triple(name, location, scope)

Expand All @@ -143,7 +143,7 @@ data class CargoDependency(
is Local -> "local"
}

fun rustName(name: String): RuntimeType = RuntimeType(name, this, this.name.replace("-", "_"))
fun rustName(name: String): RuntimeType = RuntimeType(name, this, this.rustName)

fun toMap(): Map<String, Any> {
val attribs = mutableMapOf<String, Any>()
Expand Down Expand Up @@ -199,7 +199,7 @@ data class CargoDependency(
val Hyper: CargoDependency = CargoDependency("hyper", CratesIo("0.14"))
val HyperWithStream: CargoDependency = Hyper.withFeature("stream")
val LazyStatic: CargoDependency = CargoDependency("lazy_static", CratesIo("1.4"))
val Md5: CargoDependency = CargoDependency("md5", CratesIo("0.7"))
val Md5: CargoDependency = CargoDependency("md-5", CratesIo("0.10"), rustName = "md5")
val PercentEncoding: CargoDependency = CargoDependency("percent-encoding", CratesIo("2"))
val PrettyAssertions: CargoDependency = CargoDependency("pretty_assertions", CratesIo("1"), scope = DependencyScope.Dev)
val Regex: CargoDependency = CargoDependency("regex", CratesIo("1"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class HttpChecksumRequiredGenerator(
.body()
.bytes()
.expect("checksum can only be computed for non-streaming operations");
let checksum = #{md5}::compute(data);
let checksum = <#{md5}::Md5 as #{md5}::Digest>::digest(data);
req.headers_mut().insert(
#{http}::header::HeaderName::from_static("content-md5"),
#{base64_encode}(&checksum[..]).parse().expect("checksum is valid header value")
Expand Down