Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
cms Enveloped Data binary encoding problem in pkijs

I'm trying trying to implement exchange of CMS encrypted content using the pkijs library. Basically I've just copied the example from here: https://pkijs.org/examples/CMSEnvelopedExample.html

here the excerpt for encryption

cmsEnveloped.addRecipientByCertificate(certSimpl, {  oaepHashAlgorithm: oaepHashAlg });

return cmsEnveloped.encrypt(encAlg, valueBuffer).then(() => {
  var cmsContentSimpl = new ContentInfo();
  cmsContentSimpl.contentType = "1.2.840.113549.1.7.3";
  cmsContentSimpl.content = cmsEnveloped.toSchema();
  cmsEnvelopedBuffer = cmsContentSimpl.toSchema().toBER(false);

The problematic part is the binary encoding of the asn.1 schema with .toBER(false). If the valueBuffer is not extremely small it is very slow ~13sek for 1 Mb. My question are: why is this so slow? and could I just encode it differently e.g. toJSON()and then stringToArrayBuffer? Are there any security concerns?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There was some unoptimized code in the implementation of toBER in asn1js. You should upgrade the dependency to asn1js@2.4.0 if you encounter the same problem. This is the issue on github: https://github.com/PeculiarVentures/PKI.js/issues/347

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!