File tree Expand file tree Collapse file tree 6 files changed +119
-2
lines changed 
build-logic/src/main/kotlin/ckbuild 
cryptography-providers/bouncycastle 
resources/META-INF/services Expand file tree Collapse file tree 6 files changed +119
-2
lines changed Original file line number Diff line number Diff line change @@ -25,13 +25,14 @@ object Projects {
2525        " cryptography-provider-base" setOf (Tag .PUBLISHED ),
2626        " cryptography-provider-jdk" setOf (Tag .PUBLISHED ),
2727        " cryptography-provider-jdk-bc" setOf (Tag .PUBLISHED ),
28+         " cryptography-provider-bouncycastle" setOf (Tag .PUBLISHED ),
2829        " cryptography-provider-apple" setOf (Tag .PUBLISHED ),
29-         " cryptography-provider-cryptokit" setOf (Tag .PUBLISHED ),
30+ //         "cryptography-provider-cryptokit" to setOf(Tag.PUBLISHED),
3031        " cryptography-provider-webcrypto" setOf (Tag .PUBLISHED ),
3132        " cryptography-provider-openssl3-api" setOf (Tag .PUBLISHED ),
3233        " cryptography-provider-openssl3-shared" setOf (Tag .PUBLISHED ),
3334        " cryptography-provider-openssl3-prebuilt" setOf (Tag .PUBLISHED ),
34-         " cryptography-provider-optimal" setOf (Tag .PUBLISHED ),
35+ //         "cryptography-provider-optimal" to setOf(Tag.PUBLISHED),
3536
3637        " cryptography-provider-jdk-android-tests" setOf (),
3738        " cryptography-provider-openssl3-test" setOf (),
Original file line number Diff line number Diff line change 1+ /* 
2+  * Copyright (c) 2023-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license. 
3+  */  
4+ 
5+ import  ckbuild.* 
6+ import  org.jetbrains.kotlin.gradle.* 
7+ 
8+ plugins {
9+     id(" ckbuild.multiplatform-library" 
10+     id(" ckbuild.multiplatform-provider-tests" 
11+ }
12+ 
13+ description =  " cryptography-kotlin BouncyCastle provider" 
14+ 
15+ @OptIn(ExperimentalKotlinGradlePluginApi ::class )
16+ kotlin {
17+     jvmTarget()
18+ 
19+     compilerOptions {
20+         optIn.addAll(
21+             OptIns .DelicateCryptographyApi ,
22+             OptIns .CryptographyProviderApi ,
23+         )
24+     }
25+ 
26+     sourceSets {
27+         jvmMain.dependencies {
28+             api(projects.cryptographyCore)
29+             implementation(libs.bouncycastle)
30+             //  implementation(projects.cryptographyProviderBase)
31+         }
32+     }
33+ }
34+ 
35+ providerTests {
36+     packageName.set(" dev.whyoleg.cryptography.providers.bouncycastle" 
37+     providerInitializers.put(" BouncyCastle" " CryptographyProvider.BouncyCastle" 
38+ }
Original file line number Diff line number Diff line change 1+ /* 
2+  * Copyright (c) 2023-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license. 
3+  */  
4+ 
5+ package  dev.whyoleg.cryptography.providers.bouncycastle 
6+ 
7+ import  dev.whyoleg.cryptography.* 
8+ import  dev.whyoleg.cryptography.algorithms.* 
9+ import  dev.whyoleg.cryptography.providers.jdk.algorithms.* 
10+ import  dev.whyoleg.cryptography.random.* 
11+ import  java.security.* 
12+ import  java.util.* 
13+ import  java.util.concurrent.* 
14+ 
15+ private  val  defaultProvider =  lazy { BouncyCastleCryptographyProvider  }
16+ 
17+ internal  object  BouncyCastleCryptographyProvider : CryptographyProvider() {
18+     override  val  name:  String  get() =  " BouncyCastle" 
19+ 
20+     @Suppress(" UNCHECKED_CAST" 
21+     override  fun  <A  :  CryptographyAlgorithm > getOrNull (identifier :  CryptographyAlgorithmId <A >): A ?  =  when  (identifier) {
22+         HKDF  ->  JdkHkdf (state, this )
23+         else  ->  null 
24+     } as  A ? 
25+ }
26+ 
27+ internal  class  BouncyCastleCryptographyProviderContainer  : CryptographyProviderContainer  {
28+     override  val  priority:  Int  get() =  100 
29+     override  val  provider:  Lazy <CryptographyProvider > get() =  defaultProvider
30+ }
Original file line number Diff line number Diff line change 1+ /* 
2+  * Copyright (c) 2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license. 
3+  */  
4+ 
5+ package  dev.whyoleg.cryptography.providers.bouncycastle.algorithms 
6+ 
7+ import  dev.whyoleg.cryptography.* 
8+ import  dev.whyoleg.cryptography.algorithms.* 
9+ import  dev.whyoleg.cryptography.operations.* 
10+ import  org.bouncycastle.crypto.generators.* 
11+ import  org.bouncycastle.crypto.params.* 
12+ 
13+ internal  object  BcHkdf : HKDF {
14+     override  fun  secretDerivation (
15+         digest :  CryptographyAlgorithmId <Digest >,
16+         outputSize :  BinarySize ,
17+         salt :  ByteArray? ,
18+         info :  ByteArray? ,
19+     ): SecretDerivation  {
20+ 
21+         TODO (" Not yet implemented" 
22+     }
23+ 
24+ }
25+ 
26+ private  class  BcHkdfSecretDerivation (
27+     private  val  generator :  HKDFBytesGenerator ,
28+     private  val  outputSizeBytes :  Int ,
29+     private  val  salt :  ByteArray? ,
30+     private  val  info :  ByteArray? ,
31+ ) : SecretDerivation {
32+     override  fun  deriveSecretToByteArrayBlocking (input :  ByteArray ): ByteArray  {
33+         generator.init (
34+             HKDFParameters (
35+                 /*  ikm = */ 
36+                 /*  salt = */ 
37+                 /*  info = */ 
38+             )
39+         )
40+         TODO (" Not yet implemented" 
41+     }
42+ }
Original file line number Diff line number Diff line change 1+ #
2+ # Copyright (c) 2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
3+ #
4+ 
5+ dev.whyoleg.cryptography.providers.bouncycastle.BouncyCastleCryptographyProviderContainer
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ projects("cryptography-kotlin") {
5555            module(" android-tests" 
5656            module(" bc" //  preconfigured JDK with BC provider
5757        }
58+         module(" bouncycastle" 
5859        module(" apple" 
5960        module(" webcrypto" 
6061        folder(" openssl3" 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments