Пример #1
0
 // Convert RSA public parameters into an ASN.1 buffer.
 internal void PublicToASN1(ASN1Builder builder, bool x509)
 {
     if (x509)
     {
         // Output an X.509 "SubjectPublicKeyInfo" block.
         ASN1Builder alg = builder.AddSequence();
         alg.AddObjectIdentifier(rsaID);
         alg.AddNull();
         ASN1Builder bitString = builder.AddBitStringContents();
         ASN1Builder inner     = bitString.AddSequence();
         inner.AddBigInt(Modulus);
         inner.AddBigInt(Exponent);
     }
     else
     {
         // Output a bare list of RSA parameters.
         builder.AddBigInt(Modulus);
         builder.AddBigInt(Exponent);
     }
 }
Пример #2
0
 // Convert DSA public parameters into an ASN.1 buffer.
 internal void PublicToASN1(ASN1Builder builder, bool x509)
 {
     if (x509)
     {
         // Output an X.509 "SubjectPublicKeyInfo" block.
         ASN1Builder alg = builder.AddSequence();
         alg.AddObjectIdentifier(dsaID);
         ASN1Builder inner = alg.AddSequence();
         inner.AddBigInt(P);
         inner.AddBigInt(Q);
         inner.AddBigInt(G);
         ASN1Builder bitString = builder.AddBitStringContents();
         bitString.AddBigInt(Y);
     }
     else
     {
         // Output the raw public parameters.
         builder.AddBigInt(P);
         builder.AddBigInt(Q);
         builder.AddBigInt(G);
         builder.AddBigInt(Y);
     }
 }