Comments (2)
This is (currently) a limitation of crypto11. If the SessionKeyLen
option is nonzero then it refuses to decrypt. It is documented but I appreciate that it's easy to miss if you are using it as a drop-in replacement for the native implementation.
The reason lies in the definition of the option:
// SessionKeyLen is the length of the session key that is being
// decrypted. If not zero, then a padding error during decryption will
// cause a random plaintext of this length to be returned rather than
// an error. These alternatives happen in constant time.
The reason for this behavior is Daniel Bleichenbacher's attack on the PKCS#1v1.5 padding scheme.
crypto11 could (hypothetically) replace error responses with random plaintexts, but it cannot guarantee the constant-time behavior - that is something that only the underlying PKCS#11 implementation can control.
Rather than violate the promise in the API definition, I chose to have the code fail instead. I appreciate that this is not convenient, but I think it is the safer option.
If it's a major problem then I think we could have a runtime option which accept nonzero SessionKeyLen
values and set random plaintext without the promise of constant-time behavior. It would be off by default and accompanied by a warning about the security risks of enabling it.
However, my recommendation is that you avoid ciphersuites that depend on PKCS#1v1.5 decryption, if that is possible.
References:
- https://en.wikipedia.org/wiki/Adaptive_chosen-ciphertext_attack
- https://tools.ietf.org/html/rfc5246#section-7.4.7.1
- http://archiv.infsec.ethz.ch/education/fs08/secsem/bleichenbacher98.pdf
from crypto11.
Hi @nfewx,
Thanks a lot for the detailed explanation. The course of action you suggested looks good to me. I will close this issue.
Thanks!
Varun
from crypto11.
Related Issues (20)
- FindAllKeyPairs breaks on unsupported key type
- How to use Signer to decrypt from Encrypted data ?
- FindKeyPair assumes that the public and private keys have the same labels (YubiKey) HOT 1
- FindAllKeyPairs for keys that their public key is in a X509 certificate
- Keys without id values not found HOT 1
- about demo of crypto11
- AWS CloudHSM - could not find PKCS#11 token HOT 1
- Access to attributes (CKA_*) HOT 2
- -deleted-
- Add possibility to find certificate chain
- PCKS11 new kmdata/local keydata files import
- ecdsa.unmarshalEcPoint expects ASN.1 data, but should be raw HOT 2
- Tests failing with CloudHSM (Client V5)
- How to use this library HOT 1
- Using Client Certificate in IIS Server
- Problem to run in i386 Ubuntu
- RSA OAEP SHA256 (CKM_SHA256) with SoftHSM2 HOT 1
- RFC7512 URI support HOT 1
- Abandoned? HOT 5
- Export private key HOT 4
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 crypto11.