forked from eXist-db/expath-crypto-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathencryptStringWithAesWrongSymmetricKeyCbcMode.xq
50 lines (46 loc) · 1.67 KB
/
encryptStringWithAesWrongSymmetricKeyCbcMode.xq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
(:
: eXist-db EXPath Cryptographic library
: eXist-db wrapper for EXPath Cryptographic Java library
: Copyright (C) 2016 Claudius Teodorescu
:
: This library is free software; you can redistribute it and/or
: modify it under the terms of the GNU Lesser General Public License
: as published by the Free Software Foundation; either version 2.1
: of the License, or (at your option) any later version.
:
: This library is distributed in the hope that it will be useful,
: but WITHOUT ANY WARRANTY; without even the implied warranty of
: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
: GNU Lesser General Public License for more details.
:
: You should have received a copy of the GNU Lesser General Public License
: along with this library; if not, write to the Free Software Foundation,
: Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
:)
xquery version "3.0";
import module "http://expath.org/ns/crypto";
let $expected-result := <expected-result>err:CX19: The secret key is invalid</expected-result>
let $iv := crypto:hash("initialization vector", "MD5", "")
let $actual-result :=
<actual-result>
{
try {
crypto:encrypt("Short string for tests.", "symmetric", "12345678901234567", "AES/CBC/PKCS5Padding", $iv, "SunJCE")
}
catch * {
<error>{$err:description}</error>
}
}
</actual-result>
let $condition := contains(normalize-space($actual-result/element()/text()), normalize-space($expected-result/element()/text()))
return
<result>
{
(
if ($condition)
then <result-token>passed</result-token>
else <result-token>failed</result-token>
, $actual-result
)
}
</result>