This repository has been archived by the owner on Aug 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1bc9c9a
commit cdc8bf8
Showing
15 changed files
with
373 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
kmp-advcrypto/src/androidMain/kotlin/io/karma/advcrypto/store/MemoryBuffer.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2024 Cach30verfl0w | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.karma.advcrypto.store | ||
|
||
/** | ||
* This method creates a memory buffer from the specified byte array. This can be used to | ||
* copy data directly into the byte array | ||
* | ||
* @author Cedric Hammes | ||
* @since 16/06/2024 | ||
*/ | ||
actual fun emptyBuffer(): MemoryBuffer { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
/** | ||
* This method creates a secure memory buffer based on the platform. | ||
* | ||
* @author Cedric Hammes | ||
* @since 16/06/2024 | ||
*/ | ||
actual fun secureBuffer(): MemoryBuffer { | ||
TODO("Not yet implemented") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
kmp-advcrypto/src/commonMain/kotlin/io/karma/advcrypto/store/MemoryBuffer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright (c) 2024 Cach30verfl0w | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.karma.advcrypto.store | ||
|
||
import io.karma.advcrypto.annotations.InsecureCryptoApi | ||
|
||
/** | ||
* This method creates a empty memory buffer based on the platform. | ||
* | ||
* @author Cedric Hammes | ||
* @since 16/06/2024 | ||
*/ | ||
expect fun emptyBuffer(): MemoryBuffer | ||
|
||
/** | ||
* This method creates a secure memory buffer based on the platform. | ||
* | ||
* @author Cedric Hammes | ||
* @since 16/06/2024 | ||
*/ | ||
expect fun secureBuffer(): MemoryBuffer | ||
|
||
/** | ||
* This is the implementation of a memory buffer. Memory buffers are used to provide cross-platform | ||
* copy and write operations for insecure and secure memory. | ||
* | ||
* @author Cedric Hammes | ||
* @since 16/06/2024 | ||
*/ | ||
@OptIn(ExperimentalStdlibApi::class) | ||
interface MemoryBuffer: AutoCloseable { | ||
|
||
/** | ||
* This method copies this memory buffer into another memory buffer. | ||
* | ||
* @author Cedric Hammes | ||
* @since 16/06/2024 | ||
*/ | ||
fun copyInto(buffer: MemoryBuffer, size: Int = this.size) | ||
|
||
/** | ||
* This method returns the content of the memory buffer as byte array. If you are using a secure | ||
* buffer, this data can be leaked into insecure memory. | ||
* | ||
* @author Cedric Hammes | ||
* @since 16/06/2024 | ||
*/ | ||
@InsecureCryptoApi | ||
fun toByteArray(): ByteArray | ||
|
||
val size: Int | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
kmp-advcrypto/src/jvmMain/kotlin/io/karma/advcrypto/store/MemoryBuffer.jvm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2024 Cach30verfl0w | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.karma.advcrypto.store | ||
|
||
/** | ||
* This method creates a memory buffer from the specified byte array. This can be used to | ||
* copy data directly into the byte array | ||
* | ||
* @author Cedric Hammes | ||
* @since 16/06/2024 | ||
*/ | ||
actual fun emptyBuffer(): MemoryBuffer { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
/** | ||
* This method creates a secure memory buffer based on the platform. | ||
* | ||
* @author Cedric Hammes | ||
* @since 16/06/2024 | ||
*/ | ||
actual fun secureBuffer(): MemoryBuffer { | ||
TODO("Not yet implemented") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.