|
| 1 | +const asciidoctor = require('@asciidoctor/core')() |
| 2 | +const registry = asciidoctor.Extensions.create() |
| 3 | +require('./asciidoctor-external-callout.js')(registry) |
| 4 | + |
| 5 | + |
| 6 | +require('./asciidoctor-external-callout') |
| 7 | + |
| 8 | +test('Load Simon Dew test file', () => { |
| 9 | + |
| 10 | + let input_document = ` |
| 11 | +:source-highlighter: highlight.js |
| 12 | +:icons: font |
| 13 | +[source, c] |
| 14 | +---- |
| 15 | +typedef struct CBLExternalKeyCallbacks |
| 16 | +{ |
| 17 | + /** Provides the public key's raw data as an ASN.1 DER sequence of [modulus, exponent]. */ |
| 18 | + bool (*publicKeyData)(void* externalKey, |
| 19 | + void* output, |
| 20 | + size_t outputMaxLen, |
| 21 | + size_t* outputLen); |
| 22 | +
|
| 23 | + /** Decrypts data using the private key. */ |
| 24 | + bool (*decrypt)(void* externalKey, |
| 25 | + FLSlice input, |
| 26 | + void* output, |
| 27 | + size_t outputMaxLen, |
| 28 | + size_t* outputLen); |
| 29 | +
|
| 30 | + /** Uses the private key to generate a signature of input data. */ |
| 31 | + bool (*sign)(void* externalKey, |
| 32 | + CBLSignatureDigestAlgorithm digestAlgorithm, |
| 33 | + FLSlice inputData, |
| 34 | + void* outSignature); |
| 35 | +
|
| 36 | + /** ( Optional ) For freeing any resource when the callbacks are no longer needed.*/ |
| 37 | + void (*_cbl_nullable free)(void* externalKey); |
| 38 | +} CBLKeyPairCallbacks; |
| 39 | +---- |
| 40 | +. The public key is part of an RSA key pair generated by a secure key storage or cryptographic API. @/publicKeyData/ |
| 41 | +
|
| 42 | +. \`externalKey\` is an opaque pointer passed to {url-api-references-tlsidentity}#ga78d47a8c2157dad4347709d1adec6b39[CBLKeyPair_CreateWithExternalKey()], typically representing a reference or token used to access the public / private key within the secure storage system. @/externalKey/ |
| 43 | +
|
| 44 | +. Use \`outputMaxLen\` as a guardrail to ensure the public key data size is within the expected range. @/outputMaxLen/ |
| 45 | +
|
| 46 | +. Use RSA with PKCS#1 v1.5 padding. |
| 47 | +Algorithm names may vary -- for example, RSA/ECB/PKCS1Padding on Java or Android. |
| 48 | +Note that depending on the selected key exchange method, the \`decrypt()\` function may not be invoked during the TLS handshake. @/decrypt/ |
| 49 | +
|
| 50 | +. You must use PKCS#1 v1.5 padding algorithm when generating the signature. @/CBLSignatureDigestAlgorithm/ |
| 51 | +
|
| 52 | +. Ensure that the input data, which is already hashed based on the specified digest algorithm, is encoded as an ASN.1 DigestInfo structure in DER format before performing the signing operation. |
| 53 | +Some cryptographic libraries may handle the DigestInfo formatting internally. @/inputData/ |
| 54 | +` |
| 55 | + let converted_doc = asciidoctor.convert(input_document,{safe: 'safe', standalone: true, |
| 56 | + extension_registry: registry}) |
| 57 | + |
| 58 | + |
| 59 | + console.log(converted_doc) |
| 60 | +}) |
0 commit comments