Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 3
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);
				}
			}
Ejemplo n.º 4
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);
				}
			}