Hans Leidekker (@hans) commented about dlls/cryptxml/cryptxml.c:
- signature.SignedInfo = signed_info;
- signature.SignatureValue.cbData = blob->cbData;
- signature.SignatureValue.pbData = blob->pbData;
- signature.pKeyInfo = &key_info;
- signature.cObject = 0;
- signature.rgpObject = NULL;
- signatures[0] = &signature;
- context->cbSize = sizeof( *context );
- context->hDocCtxt = (HCRYPTXML)context;
- context->pTransformsConfig = (CRYPT_XML_TRANSFORM_CHAIN_CONFIG *)config;
- context->cSignature = 1;
- context->rgpSignature = signatures;
- *handle = (HCRYPTXML)context;
I know it's a stub but using static variables is not thread-safe. You should also (deep) copy the config and blob parameters since they may not survive after the call returns. Ignoring the optional config parameter for now is fine too. I would define a structure that holds everything needed and return that in the handle parameter, something like this:
``` struct xmldoc { ULONG magic; CRYPT_XML_DOC_CTXT ctx; CRYPT_XML_SIGNATURE sig; } ```