AES encryption from XQuery?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

AES encryption from XQuery?

Olaf Schreck
Hi,

assume I want to AES encrypt a plaintext string in XQuery like this

 let $bitstring := encrypt-aes-128($plaintext,$key)
 return encode-somehow($bitstring)

what options do I have?

There is no native encrypt() function in eXist?  or am I just blind?

There is EXpath crypto, downloaded it, but usage is not obvious to me.
Amyone have examples?  Is this actively maintained?  Would you use it?

Use Java classes from XQuery?


Thanks for your comments,
Olaf

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: AES encryption from XQuery?

Michael Westbay-2
Schreck-san,

in eXist's Dashboard, use the Package Manager to install the EXPath Cryptographic Module. There is an EXPath Cryptographic Module Demos package as well to show how to use it.

In short, it's a plugin, not part of the XQuery standard.

Hope this helps.



2016-12-06 12:09 GMT+09:00 Olaf Schreck <[hidden email]>:
Hi,

assume I want to AES encrypt a plaintext string in XQuery like this

 let $bitstring := encrypt-aes-128($plaintext,$key)
 return encode-somehow($bitstring)

what options do I have?

There is no native encrypt() function in eXist?  or am I just blind?

There is EXpath crypto, downloaded it, but usage is not obvious to me.
Amyone have examples?  Is this actively maintained?  Would you use it?

Use Java classes from XQuery?


Thanks for your comments,
Olaf

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open



--
Michael Westbay
Writer/System Administrator
http://www.japanesebaseball.com/

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: AES encryption from XQuery?

Olaf Schreck
> in eXist's Dashboard, use the Package Manager to install the EXPath
> Cryptographic Module.

Did that, got version 0.3.4.  Was looking for the demos.

> There is an EXPath Cryptographic Module Demos package
> as well to show how to use it.

Yes.  Actually no.  When I choose to install "EXPath Cryptographic Module
Demos" in Package Manager, all I get is library version 0.3.3, but no
demos.

Looks like a packaging bug..  Was testing with "develop" branch, I'd better
pull and rebuild, and return to whining about missing demos later :)


Olaf

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: AES encryption from XQuery?

Joe Wicentowski
Hi Olaf,

I haven't used the EXPath Crypto library for AES, but I have used it
for HMAC-SHA1 hashing.  Sample code:

  https://github.com/HistoryAtState/twitter/blob/master/modules/oauth.xqm#L65

For AES, I think you'd use the crypto:encrypt() and crypto:decrypt()
functions documented at:

  http://expath.org/spec/crypto#d3e410

The spec doesn't say which values are allowed for the
$cryptographic-algorithm parameter, but judging from the source for
the underlying libraries...

  https://github.com/claudius108/crypto-java-lib/tree/master/src/test/java/ro/kuberam/libs/java/crypto/encrypt

You should be able to use "AES".

Claudius Teodorescu, the author of the spec and the libraries - and
copied here - may have some other pointers.

As to your problems downloading/installing the .xars for the library
and demos, which version of eXist are you using?

Thanks!
Joe

On Tue, Dec 6, 2016 at 4:56 PM, Olaf Schreck <[hidden email]> wrote:

>> in eXist's Dashboard, use the Package Manager to install the EXPath
>> Cryptographic Module.
>
> Did that, got version 0.3.4.  Was looking for the demos.
>
>> There is an EXPath Cryptographic Module Demos package
>> as well to show how to use it.
>
> Yes.  Actually no.  When I choose to install "EXPath Cryptographic Module
> Demos" in Package Manager, all I get is library version 0.3.3, but no
> demos.
>
> Looks like a packaging bug..  Was testing with "develop" branch, I'd better
> pull and rebuild, and return to whining about missing demos later :)
>
>
> Olaf
>
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today.http://sdm.link/xeonphi
> _______________________________________________
> Exist-open mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/exist-open

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: AES encryption from XQuery?

Claudius Teodorescu
Hi,

You should b able to use AES.

After installing the EXPath Cryptographic Module Implementation (pay attention to install the one that requires eXist-db version 2.3.0 or later), you can install the demos, EXPath Cryptographic Module Demos, or you can look for the XQuery examples at https://github.com/claudius108/crypto-exist-java-lib/tree/master/src/test/java/org/expath/exist/crypto/xquery.


Claudius
Reply | Threaded
Open this post in threaded view
|

Re: AES encryption from XQuery?

Olaf Schreck
In reply to this post by Joe Wicentowski
Joe, Claudius,

thanks!  that's what I was looking for.

> As to your problems downloading/installing the .xars for the library
> and demos, which version of eXist are you using?

I'm running a checkout of the github "develop" branch roughly 4 weeks old:

  $ cat VERSION.txt
  #eXist build info
  project.version=3.0.RC2
  project.built=20161109083922
  scm.branch=develop
  scm.revision=e12f039

I have reproduced the problem.  In Package Manager, removed all installed
"crypto" packages.  Did not install the crypto lib itself, just clicked to
install the Demo package.  That installed the older 0.3.3 version of the
crypto lib, and not the demos.


Thanks again,
Olaf

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open