aes-gcm | Standalone AES-GCM library | TLS library
kandi X-RAY | aes-gcm Summary
kandi X-RAY | aes-gcm Summary
Standalone AES-GCM library (pulled out of mbed TLS)
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of aes-gcm
aes-gcm Key Features
aes-gcm Examples and Code Snippets
Community Discussions
Trending Discussions on aes-gcm
QUESTION
I've created a TypeScript example from MDN example as verbatim as I could to illustrate. It encrypts and decrypts just fine. I just noticed that, for Decryption to work, it requires the same init_vector
from encryption. Isn't the init_vector
supposed to be a nonce?
How is the person receiving the message going to know what the init_vector
I've used for encryption if decryption is a separate process done at a different place and time?
ANSWER
Answered 2022-Apr-09 at 05:38You should use asymmetric encryption like RSA which has a public / private key, for example this node-rsa package.
In terms of having the same initial vector, I found this snippet taken from this answer:
In any case, the IV never needs to be kept secret — if it did, it would be a key, not an IV. Indeed, in most cases, keeping the IV secret would not be practical even if you wanted to since the recipient needs to know it in order to decrypt the data (or verify the hash, etc.).
QUESTION
I'm starting to implement AES-GCM on STM32H753 (rev V).
I've found an inconsistency between the HAL and the Ref Manual.
The STMicro HAL for AES for STM32H7x3 is setting some bits called NPBLB
in CRYP_CR
register if the product revision is above rev B.
But these bits are not documented in the ref manual rev 7.
Is it just an error of the HAL ?
...ANSWER
Answered 2022-Apr-05 at 12:34It is common for the IP blocks to be shared between different STM32 families, so if you cannot find info in the reference manual of your device, it is worth looking at the documentation of other devices.
AN5312 mentions that NPBLB bits were added in revision V, but gives no documentation about the meaning of the bits:
RevV supports hardware management for GCM encryption or CCM decryption with the last block of payload size inferior to 128 bits. This is possible thanks to the addition of the NPBLB bit field (the highlighted cells in Figure 5) in the CRYP_CR register.
The reference manual of STM32MP1, however, has the description of these bits, as shown below:
QUESTION
I'm generating a key for encrypting data, then wrap it using a master key and store it alongside the encrypted data. All is well when wrapping into raw
format, but when wrapping as jwk
I get the error DOMException: Data provided to an operation does not meet requirements
.
It works when specifying they key for being used either for encryption or for decryption, but not when both are specified as key usages.
...ANSWER
Answered 2022-Mar-06 at 16:30AES-KW is a key wrap algorithm described in RFC3394. The algorithm is used to wrap i. e. encrypt a key. The input, i.e. the key to be encrypted, must be an integer multiple of 8 bytes, s. also here.
The key to be encrypted is passed in SubtleCrypto.wrapKey()
in the 2nd parameter key
as CryptoKey
and must therefore be exported before the actual encryption. For this purpose the format in which the key is exported is specified in the 1st parameter format
:
QUESTION
I encrypt a text in Java and want to decrypt in Javascript and vice versa, my Java code looks like this
...ANSWER
Answered 2022-Feb-07 at 15:56The GCM mode uses by definition a tag which is needed for the authenticity/integrity check.
The tag issue on the NodeJS side is caused by not taking the authentication tag into account. On the Java side this is not necessary because the SunJCE provider does this automatically by appending the tag to the ciphertext: Therefore, the last 16 bytes of the result are the tag. On the NodeJS side, in contrast, ciphertext and tag are handled detached, so that both parts must be explicitly separated, e.g.:
QUESTION
I'm looking for a complete JS crypto library: all SHAs, AEAD (chacha/poly, aes-gcm), all AESs, NIST and SECP P256 and ED25519 support, ECDSA, ECDH/E, etc.
It looks like the nodeJS crypto module has full support of everything I need, but it says it is a wrapper around OpenSSL.
Does this mean some functions may not work if a user does not have OpenSSL installed (or an outdated version)? I assume it does, but that is very unlike Node, so I want to be sure.
If so, are there are any "complete" libraries out there? libsodium, sjcl, and crypto-js are insufficient (I could piece together a sol'n from multiple libs if necessary).
...ANSWER
Answered 2022-Jan-15 at 06:29Nodejs is statically linked to its own built-in version of OpenSSL. It does not rely on an external OpenSSL installation.
There are multiple articles that reference how nodejs has to be updated in order to get the newer OpenSSL versions (because it links OpenSSL right into nodejs).
Here are a couple of those articles:
https://nodejs.org/ru/blog/vulnerability/april-2020-openssl-updates/
QUESTION
We are implementing encryption at rest in Kubernetes by this tutorial (https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data/) and we are absolutely not sure why AES-GCM encryption provider requires to rotate the key every 200K writes, because of lack of knowledge about how encryption works. Also, what exactly means: "200K writes", how can we define that we should rotate the key? Thank you
...ANSWER
Answered 2022-Jan-02 at 15:20As per OpenShift docs: https://docs.openshift.com/container-platform/3.11/admin_guide/encrypting_data.html
Kubernetes has no proper nonce generator and uses a random IV as nonce for AES-GCM. Since AES-GCM requires a proper nonce to be secure, AES-GCM is not recommended. The 200,000 write limit just limits the possibility of a fatal nonce misuse to a reasonable low margin.
It's just an arbitrary number from what I can see.
QUESTION
We have an Expo React Native Project utilizing encryption. Our current encryption is based on SubtleCrypto / Web API [window.subtle.crypto], using AES-GCM 128, now we need to use a library that is universally available on all platforms [Web, iOS and Android], from my previous question, we've found SJCL that supports GCM mode and we can completely replace all the web-only based code BUT the challenge is that we need to ensure that all the current encrypted data is decrypted at this new library too, we have to make it so:
window.crypto.subtle.encrypt [AES-GCM 128] => (a) ---> SJCL.mode.gcm.decrypt(a)
Once we can do that successfully, we can fully replace the library and have universal platform support as well as backwards compatibility.
This means that we cannot change the way encryption is handled at all, as that is the requirement, and we're encrypting it exactly as the code below.
I got a very good lead here by Neneil94 but I'm still facing issues at encoding / formats; and here's the current code:
...ANSWER
Answered 2021-Dec-12 at 11:35There are two problems in your code:
kkey
is the Base64url encoded raw key. This must first be converted to Base64 and then to a bitArray:
QUESTION
I've Encrypted my text by a key in Client by AES-256-GCM algorithm and I can decrypt it in Client, But when I send it to the Backend which has a SharedKey
(the same as the Client has), it can decrypt the message by AES-256-CTR algorithm(I used this algo because the AES-256-GCM in Nodejs needs authTag
that I don't create it in Client and iv
is the only thing I have).
When I decrypt the message on the Backend side, it works with no error, but the result is not what I encrypted in the Client
Here is what I wrote: Client:
...ANSWER
Answered 2021-Sep-11 at 08:13Since GCM is based on CTR, decryption with CTR is in principle also possible. However, this should generally not be done in practice, since it skips the authentication of the ciphertext, which is the added value of GCM over CTR.
The correct way is to decrypt on the NodeJS side with GCM and properly consider the authentication tag.
The authentication tag is automatically appended to the ciphertext by the WebCrypto API, while the crypto module of NodeJS handles ciphertext and tag separately. Therefore, not only the nonce but also the authentication tag must be separated on the NodeJS side.
The following JavaScript/WebCrypto code demonstrates the encryption:
QUESTION
I generate a pair public/private key on Client and send the publicKey
to the Server and the backend will generate a sharedKey
on its side and respond me a publicKey
which help me to generate a sharedKey
on the client too for encryption/decryption. So I encrypt a message by AES-256-GCM on Nodejs and decrypted the message on the Client.
Backend-Side:
...ANSWER
Answered 2021-Sep-11 at 14:13GCM uses an authentication tag that is handled separately by NodeJS/Crypto, while WebCrypto automatically concatenates it with the ciphertext.
Therefore, in the NodeJS code, the tag must be explicitly determined and appended to the ciphertext. This is missing in the current NodeJS code and can be taken into account as follows. Note the determination of the tag with cipher.getAuthTag()
and its concatenation:
QUESTION
I tried to search stackoverflow for an answer to this particular question but couldn't find a good answer.
The BouncyCastle API offers a ton of different encryption algorithms for .NET. In this case I have to select an encryption algorithm for the following use case:
Encrypting several thousand short strings for storage in an unencrypted file, typical length 10-30 characters.
Encryption needs to be only moderately secure, all strings will be encrypted with the same key but a different initialization vector. Things like authorization (like in AES-GCM) are not needed.
Which encryption algorithm is both fastest and straightforward to apply for encrypting and decrypting such a set of several thousand small strings? I will store the encrypted data of each string as BASE64 in the file.
Thank you for your advice!
...ANSWER
Answered 2021-Jul-12 at 09:13That processor still has AES-NI, so using that through the AES.Create
seems most logical. A higher end solution would be to create CTR mode out of ECB (and cache the key streams).
Otherwise you are looking for a fast stream cipher in software. You could check if Salsa20 is working for you. Unfortunately that's the only eStream-compatible cipher that I can find in Bouncy Castle for C#.
Note that you may want to look into multi-threading and I would certainly check if it is possible to use sequential nonce when using a stream cipher, as generating a 128 bit random value for each encryption seems wasteful.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install aes-gcm
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page