Skip to content

Commit

Permalink
Add test for content encryption with non-utf8 encoding (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
lsh123 authored Jul 5, 2023
1 parent 95b9c3a commit 1f2d229
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 2 deletions.
9 changes: 9 additions & 0 deletions tests/aleksey-xmlenc-01/enc-content-isolatin1.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<PaymentInfo xmlns="http://example.org/paymentv2">
<Name>�</Name>
<CreditCard Currency="USD" Limit="5,000">
<Number>4019 2445 0277 5567</Number>
<Issuer>�</Issuer>
<Expiration Time="04/02"/>
</CreditCard>
</PaymentInfo>
18 changes: 18 additions & 0 deletions tests/aleksey-xmlenc-01/enc-content-isolatin1.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<EncryptedData xmlns="http://www.w3.org/2001/04/xmlenc#" Type="http://www.w3.org/2001/04/xmlenc#Content">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<KeyName>my-key</KeyName>
</KeyInfo>
<CipherData>
<CipherValue></CipherValue>
</CipherData>
</EncryptedKey>
</KeyInfo>
<CipherData>
<CipherValue></CipherValue>
</CipherData>
</EncryptedData>
33 changes: 33 additions & 0 deletions tests/aleksey-xmlenc-01/enc-content-isolatin1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<PaymentInfo xmlns="http://example.org/paymentv2">
<Name>�</Name>
<CreditCard Currency="USD" Limit="5,000"><EncryptedData xmlns="http://www.w3.org/2001/04/xmlenc#" Type="http://www.w3.org/2001/04/xmlenc#Content">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<KeyName>my-key</KeyName>
</KeyInfo>
<CipherData>
<CipherValue>Gt2DBT5GnUfQ7JEiynwXkhlJmdEufS7we2gdMAj0shB4dkQKo0EFfpijeXDVS8pq
uIgqa0aqXAJSExe5Rp+qRr/+oM591agZG80x2AP0WDbbGm5FGF3BUDs2s2O+uldM
DB4Et0aU5QHhYTDunxebAsHs8Wc4+wA5lK3xd9VxvZsyTOLXyJGclxupQJnItZJF
zjulJB+/HoTEB/1+X1zT5R9gtmkdb2Mjrf3AzHDFR2Qj8V3g8Tko0BDMLAIF9xuG
glKzIKqMaktRcgy/950jIGHELjBMmxpH7PKqbY8MRNbWPsdamip0rmh6XG857+CQ
MgEbM/1SPiIKG2nyXwD/NcUjd4R41x9HLkYGODIK7KfUxvtI1gU/0D8wUNO7neP4
H140X3FygaoBRFTudMJb74LSO7c57Upa9W4oTLJMXF1zVomm12h+y6CjL5bikjfb
0yLkXn6PklqjQn1+AdDeEn7JZYELhwCa9eU7zJ943EmTctDAwBiFu/IsUE1uscYg
mO/OCnUMM3jwwJvagd0hk52VKXLiUXiWcZfGxz/OSDy/GVXN9TyVh3FQk+5aBl7v
6VmcvZFHbsqhmgkLyy0ZbAxJMBrGTcXZMUwigF4tDsmv6y2JyST8KXb+zxej9zRM
fXSYbc8NYQYrcVcWbkUiONLNPp1usn9UHdMqVZkUoqs=</CipherValue>
</CipherData>
</EncryptedKey>
</KeyInfo>
<CipherData>
<CipherValue>hpgY0A0W/FCv5czKoOqyATuQI1nPQksb1IPyar7IRPovwCy7MPjyiL7o7Mxm6moe
vyB5wBr9Epx2y7MbMFBRaSUiNtMKPNVMn7tjOUyRTyN1KOcHVF39C3b4rLVQ56vK
Ybq+zQCGelHfBbO2kFRIhlhU9S7JPF+Wyxd14tijlTk=</CipherValue>
</CipherData>
</EncryptedData></CreditCard>
</PaymentInfo>
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 11 additions & 2 deletions tests/testEnc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,20 @@ execEncTest $res_success \

execEncTest $res_success \
"" \
"aleksey-xmlenc-01/isolatin1" \
"aleksey-xmlenc-01/enc-element-isolatin1" \
"aes256-cbc rsa-1_5" \
"x509" \
"$priv_key_option:my-key $topfolder/keys/largersakey.$priv_key_format --pwd secret123" \
"--session-key aes-256 --xml-data $topfolder/aleksey-xmlenc-01/isolatin1.data --pubkey-cert-$cert_format:my-key $topfolder/keys/largersacert.$cert_format" \
"--session-key aes-256 --xml-data $topfolder/aleksey-xmlenc-01/enc-element-isolatin1.data --pubkey-cert-$cert_format:my-key $topfolder/keys/largersacert.$cert_format" \
"$priv_key_option:my-key $topfolder/keys/largersakey.$priv_key_format --pwd secret123"

execEncTest $res_success \
"" \
"aleksey-xmlenc-01/enc-content-isolatin1" \
"aes256-cbc rsa-1_5" \
"x509" \
"$priv_key_option:my-key $topfolder/keys/largersakey.$priv_key_format --pwd secret123" \
"--session-key aes-256 --xml-data $topfolder/aleksey-xmlenc-01/enc-content-isolatin1.data --node-name http://example.org/paymentv2:CreditCard --pubkey-cert-$cert_format:my-key $topfolder/keys/largersacert.$cert_format" \
"$priv_key_option:my-key $topfolder/keys/largersakey.$priv_key_format --pwd secret123"

execEncTest $res_success \
Expand Down

0 comments on commit 1f2d229

Please sign in to comment.