Comments (4)
source should be a context variable containing ciphertext. not a ciphertext. Check the README for documentation and examples.
from apigee-custompolicy-aescrypto.
This applies to GCM mode.
When the action
is Encrypt, the authentication tag is appended to the output ciphertext. You can specify the number of bits to use for the tag with the tag-bits
property. It defaults to 128 bits, or 16 bytes. If you want to extract the tag from the ciphertext, you can do that after the fact, by just grabbing the last 16 bytes of the ciphertext (or whatever tag length you used).
When the action
is Decrypt, you can simply provide the ciphertext with the tag appended. If you happen to have a ciphertext and a separate tag, in other words if you have a ciphertext from a system that emits the tag separately, you can specify them both (the latter with the tag
property), and the callout will "do the right thing".
I'll update the README to clarify this.. I just checked the README and it's pretty clear on this point, so I haven't updated it.
from apigee-custompolicy-aescrypto.
@DinoChiesa Thanks for your quick response ,, I would like to ask you what If I wan to make AES GCM Encryption
Is my request correct ? I am wondering why it's not return the tag
so I can use it when I decrypt the cipher-text
Curl Request:
curl --location --request POST 'http://XXXXXXXXX/aesjavatest/v1/encrypt' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode '[email protected]' \
--data-urlencode 'iv=c5b4039aadf01a1da13d04570da45265' \
--data-urlencode 'key=c5b4039aadf01a1da13d04570da45265' \
--data-urlencode 'aad=eyJ0eXAiOiJKV1QiLCJoZHIxIjoxMjMsImVuYyI6IkExMjhHQ00iLCJoZHIyIjp0cnVlLCJhbGciOiJSU0EtT0FFUC0yNTYifQ'
JavaCallout :
<DisplayName>Java Callout-3</DisplayName>
<Properties>
<Property name="action">encrypt</Property>
<Property name="debug">true</Property>
<Property name="mode">GCM</Property>
<Property name="padding">NoPadding</Property>
<Property name="key">{request.formparam.key}</Property>
<!--<Property name="decode-key">base64url</Property>-->
<Property name="iv">{request.formparam.iv}</Property>
<!--<Property name="decode-iv">base64url</Property>-->
<Property name="source">request.formparam.cleartext</Property>
<Property name="decode-source">none</Property>
<Property name="aad">{request.formparam.aad}</Property>
<Property name='encode-result'>base64</Property>
<!--<Property name="utf8-decode-result">true</Property>-->
</Properties>
<ClassName>com.google.apigee.callouts.AesCryptoCallout</ClassName>
<ResourceURL>java://apigee-callout-aes-crypto-20211122a.jar</ResourceURL>
</JavaCallout>
Response:
{
"ciphertext": "AJnQOEIOYvYUYhGM5Vkh8IZ7LCqb05JK2RPkrG7904E=",
"encoding": "base64",
"cipher": "AES/GCM/NoPadding",
"params": {
"b16": {
"key": "6335623430333961616466303161316461313364303435373064613435323635",
"iv": "6335623430333961616466303161316461313364303435373064613435323635"
},
"b64": {
"key": "YzViNDAzOWFhZGYwMWExZGExM2QwNDU3MGRhNDUyNjU=",
"iv": "YzViNDAzOWFhZGYwMWExZGExM2QwNDU3MGRhNDUyNjU="
}
},
"note": "To decrypt, you must pass the ciphertext, and a key and an IV."
}
from apigee-custompolicy-aescrypto.
@DinoChiesa Thanks everything works fine now.
from apigee-custompolicy-aescrypto.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apigee-custompolicy-aescrypto.