Skip to content

Commit

Permalink
Remove unused sha1Hash code (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmook authored Jun 20, 2023
1 parent bfb437f commit eeb23d2
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 19 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper
import java.net.URI

buildscript {
repositories {
Expand All @@ -19,7 +20,6 @@ buildscript {

plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.owaspDependencyCheckPlugin)
alias(libs.plugins.markdownlintGradlePlugin)
alias(libs.plugins.gradleMavenPublishPlugin) apply false
alias(libs.plugins.dokkaPlugin)
Expand All @@ -46,7 +46,7 @@ subprojects {

sourceLink {
localDirectory.set(rootDir)
remoteUrl.set(java.net.URL("https://github.com/appmattus/certificatetransparency/blob/main"))
remoteUrl.set(URI("https://github.com/appmattus/certificatetransparency/blob/main").toURL())
remoteLineSuffix.set("#L")
}
}
Expand Down
1 change: 1 addition & 0 deletions certificatetransparency/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ dependencyCheck {
suppressionFile = file("cve-suppressions.xml").toString()

analyzers.assemblyEnabled = false
analyzers.ossIndex.enabled = false

skipConfigurations = listOf(
"lintClassPath", "jacocoAgent", "jacocoAnt", "kotlinCompilerClasspath", "kotlinCompilerPluginClasspath",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ import java.security.MessageDigest
import java.security.PublicKey

internal fun PublicKey.sha256Hash(): ByteArray = MessageDigest.getInstance("SHA-256").digest(encoded)

internal fun PublicKey.sha1Hash(): ByteArray = MessageDigest.getInstance("SHA-1").digest(encoded)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Appmattus Limited
* Copyright 2021-2023 Appmattus Limited
* Copyright 2019 Babylon Partners Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -38,17 +38,4 @@ internal class PublicKeyExtTest {
// openssl x509 -in test-cert.pem -pubkey -noout | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64
assertEquals("Ojz4hdfbFTowDio/KDGC4/pN9dy/EBfIAsnO2yDbKiE=", hash)
}

@Test
fun sha1Hash() {
// given a certificate
val certificate = TestData.loadCertificates(TestData.TEST_CERT)[0]

// when we hash the public key using SHA1
val hash = Base64.toBase64String(certificate.publicKey.sha1Hash())

// then the result matches openssl generated using:
// openssl x509 -in test-cert.pem -pubkey -noout | openssl pkey -pubin -outform der | openssl dgst -sha1 -binary | openssl enc -base64
assertEquals("3VE6e2DtM3cCmvh1ScSFnSENktA=", hash)
}
}
2 changes: 1 addition & 1 deletion sampleapp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.androidX.compose.compiler.get()
}
packagingOptions {
packaging {
resources.excludes.add("META-INF/DEPENDENCIES")
resources.excludes.add("META-INF/atomicfu.kotlin_module")
}
Expand Down

0 comments on commit eeb23d2

Please sign in to comment.