-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(writer): remove unavailable interfaces
- Loading branch information
Showing
12 changed files
with
63 additions
and
66 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
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
2 changes: 1 addition & 1 deletion
2
tink/src/commonMain/kotlin/io/github/ryunen344/tink/BinaryKeysetWriter.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package io.github.ryunen344.tink | ||
|
||
expect class BinaryKeysetWriter : KeysetWriter | ||
expect class BinaryKeysetWriter() : KeysetWriter |
3 changes: 0 additions & 3 deletions
3
tink/src/commonMain/kotlin/io/github/ryunen344/tink/JsonKeysetWriter.kt
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
tink/src/commonMain/kotlin/io/github/ryunen344/tink/KeysetHandle.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
51 changes: 33 additions & 18 deletions
51
tink/src/commonTest/kotlin/io/github/ryunen344/tink/KeysetWriterTest.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 |
---|---|---|
@@ -1,28 +1,43 @@ | ||
package io.github.ryunen344.tink | ||
|
||
import io.github.ryunen344.tink.aead.AeadConfig | ||
import io.github.ryunen344.tink.aead.register | ||
import io.github.ryunen344.tink.daead.DeterministicAeadConfig | ||
import io.github.ryunen344.tink.daead.register | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class KeysetWriterTest { | ||
@Test | ||
fun test_read() { | ||
runCatching { | ||
AeadConfig.register() | ||
val handle = KeysetHandleGenerator.generateNew(KeyTemplateSet.AES256_GCM.template()) | ||
val writer = JsonKeysetWriter() | ||
handle.writeCleartext(writer) | ||
println(writer.write().decodeToString()) | ||
}.onFailure { | ||
it.printStackTrace() | ||
} | ||
DeterministicAeadConfig.register() | ||
val handle = KeysetHandleGenerator.readClearText(JsonKeysetReader(JSON_DAEAD_KEYSET)) | ||
val writer = BinaryKeysetWriter() | ||
handle.writeCleartext(writer) | ||
assertEquals( | ||
DAEAD_KEYSET_CONTENT, | ||
writer.write().contentToString() | ||
) | ||
} | ||
} | ||
|
||
// {"primaryKeyId":1767300617,"key":[{"keyData":{"typeUrl":"type.googleapis.com/google.crypto.tink.AesGcmKey","value":"GiAJ8tStZdr5C1KQ7EJUOO57IkyKuFUXLvSJBTcQTdhgkw==","keyMaterialType":"SYMMETRIC"},"status":"ENABLED","keyId":1767300617,"outputPrefixType":"TINK"}]} | ||
private companion object { | ||
val JSON_DAEAD_KEYSET = """ | ||
{ | ||
"primaryKeyId": 961932622, | ||
"key": [ | ||
{ | ||
"keyData": { | ||
"typeUrl": "type.googleapis.com/google.crypto.tink.AesSivKey", | ||
"keyMaterialType": "SYMMETRIC", | ||
"value": "EkCJ9r5iwc5uxq5ugFyrHXh5dijTa7qalWUgZ8Gf08RxNd545FjtLMYL7ObcaFtCSkvV2+7u6F2DN+kqUjAfkf2W" | ||
}, | ||
"outputPrefixType": "TINK", | ||
"keyId": 961932622, | ||
"status": "ENABLED" | ||
} | ||
] | ||
} | ||
""".trimIndent() | ||
|
||
// content [8, -70, -59, -34, -40, 12, 18, 100, 10, 88, 10, 48, 116, 121, 112, 101, 46, 103, 111, 111, 103, 108, 101, 97, 112, 105, 115, 46, 99, 111, 109, 47, 103, 111, 111, 103, 108, 101, 46, 99, 114, 121, 112, 116, 111, 46, 116, 105, 110, 107, 46, 65, 101, 115, 71, 99, 109, 75, 101, 121, 18, 34, 26, 32, 110, -6, 90, 23, -77, 39, 59, 107, -36, -94, 14, -51, 64, 20, -117, 48, -23, 121, 97, 100, 105, 2, -127, 98, 17, 104, 117, -88, 44, -53, 16, -119, 24, 1, 16, 1, 24, -70, -59, -34, -40, 12, 32, 1] | ||
// nsstring null | ||
// ����d | ||
// X | ||
// 0type.googleapis.com/google.crypto.tink.AesGcmKey" n�Z�';kܢ�@�0�yadi�bhu�,������ | ||
val DAEAD_KEYSET_CONTENT = | ||
"[8, -50, -38, -41, -54, 3, 18, -124, 1, 10, 120, 10, 48, 116, 121, 112, 101, 46, 103, 111, 111, 103, 108, 101, 97, 112, 105, 115, 46, 99, 111, 109, 47, 103, 111, 111, 103, 108, 101, 46, 99, 114, 121, 112, 116, 111, 46, 116, 105, 110, 107, 46, 65, 101, 115, 83, 105, 118, 75, 101, 121, 18, 66, 18, 64, -119, -10, -66, 98, -63, -50, 110, -58, -82, 110, -128, 92, -85, 29, 120, 121, 118, 40, -45, 107, -70, -102, -107, 101, 32, 103, -63, -97, -45, -60, 113, 53, -34, 120, -28, 88, -19, 44, -58, 11, -20, -26, -36, 104, 91, 66, 74, 75, -43, -37, -18, -18, -24, 93, -125, 55, -23, 42, 82, 48, 31, -111, -3, -106, 24, 1, 16, 1, 24, -50, -38, -41, -54, 3, 32, 1]" | ||
} | ||
} |
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
7 changes: 0 additions & 7 deletions
7
tink/src/iosMain/kotlin/io/github/ryunen344/tink/JsonKeysetWriter.kt
This file was deleted.
Oops, something went wrong.
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