Changes

Jump to navigation Jump to search
187 bytes added ,  15:34, 27 February 2020
no edit summary
|Return message authentication code (MAC) for a given string:
'''Query:'''
<pre classsyntaxhighlight lang="brush:xquery">
crypto:hmac('message', 'secretkey', 'md5', 'hex')
</presyntaxhighlight>
'''Result:'''
<pre classsyntaxhighlight lang="brush:xml">
34D1E3818B347252A75A4F6D747B21C2
</presyntaxhighlight>
|}
| '''Example'''
|Encrypt input data:
<pre classsyntaxhighlight lang="brush:xquery">
crypto:encrypt('message', 'symmetric', 'keykeyke', 'DES')
</presyntaxhighlight>
|}
|Decrypt input data and return original string:
'''Query:'''
<pre classsyntaxhighlight lang="brush:xquery">
let $encrypted := crypto:encrypt('message', 'symmetric', 'keykeyke', 'DES')
return crypto:decrypt($encrypted, 'symmetric', 'keykeyke', 'DES')
</presyntaxhighlight>
'''Result:'''
<pre classsyntaxhighlight lang="brush:xml">
message
</presyntaxhighlight>
|}
'''XML Signature'''
<pre classsyntaxhighlight lang="brush:xml">
<Signature>
<SignedInfo>
<Object/>
</Signature>
</presyntaxhighlight>
* '''SignedInfo''' contains or references the signed data and lists algorithm information
The {{Code|generate-signature}} function allows to pass a {{Code|digital certificate}}. This certificate holds parameters that allow to access key information stored in a Java key store which is then used to sign the input document. Passing a {{Code|digital certificate}} simply helps re-using the same key pair to sign and validate data. The {{Code|digital certificate}} is passed as a node and has the following form:
<pre classsyntaxhighlight lang="brush:xml">
<digital-certificate>
<keystore-type>JKS</keystore-type>
<keystore-uri>...</keystore-uri>
</digital-certificate>
</presyntaxhighlight>
==crypto:generate-signature==
'''Query:'''
<pre classsyntaxhighlight lang="brush:xquery">
crypto:generate-signature(<a/>, '', '', '', '', '')
</presyntaxhighlight>
'''Result:'''
<pre classsyntaxhighlight lang="brush:xml">
<a>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
</Signature>
</a>
</presyntaxhighlight>
|}
'''Query:'''
<pre classsyntaxhighlight lang="brush:xquery">
let $sig := crypto:generate-signature(<a/>, '', '', '', '', '')
return crypto:validate-signature($sig)
</presyntaxhighlight>
'''Result:'''
<pre classsyntaxhighlight lang="brush:xml">
true
</presyntaxhighlight>
|}
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu