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

472
Views
Decodificando las claves de RSACryptoServiceProvider

Estoy tratando de extraer las claves privadas de un objeto RSACryptoServiceProvider usando .ExportRSAPrivateKey() . Según MSDN , exporta una "matriz de bytes que contiene la representación PKCS#1 RSAPrivateKey de esta clave", cuya representación se define en el Apéndice A de RFC8017 . Entonces, en base a eso, asumo que debería estar codificado en ASN1 e intentar usar una clase AsnReader :

 using (var rsa = new RSACryptoServiceProvider(1024)) { var priv = rsa.ExportRSAPrivateKey(); var asnr = new AsnReader(priv, AsnEncodingRules.DER); var N = asnr.ReadInteger(); }

Sin embargo, este código falla en .ReadInteger() con la excepción: "The provided data is tagged with 'Universal' class value '16', but it should have been 'Universal' class value '2'."

¿Qué estoy haciendo mal?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Es porque RSAPublicKey es una SECUENCIA...

Así que tienes que leer una secuencia y luego, el entero...

Supongo que estás usando la clase Microsoft AsnReader

Entonces, el código podría ser algo como:

 var publicKey = asnr.ReadSequence() var N = publickKey.ReadInteger()
over 4 years ago · Santiago Trujillo 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!