Initial Commit
This commit is contained in:
82
iTechSharp/srcbc/asn1/sec/ECPrivateKeyStructure.cs
Normal file
82
iTechSharp/srcbc/asn1/sec/ECPrivateKeyStructure.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using Org.BouncyCastle.Asn1;
|
||||
using Org.BouncyCastle.Math;
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Sec
|
||||
{
|
||||
/**
|
||||
* the elliptic curve private key object from SEC 1
|
||||
*/
|
||||
public class ECPrivateKeyStructure
|
||||
: Asn1Encodable
|
||||
{
|
||||
private readonly Asn1Sequence seq;
|
||||
|
||||
public ECPrivateKeyStructure(
|
||||
Asn1Sequence seq)
|
||||
{
|
||||
if (seq == null)
|
||||
throw new ArgumentNullException("seq");
|
||||
|
||||
this.seq = seq;
|
||||
}
|
||||
|
||||
public ECPrivateKeyStructure(
|
||||
BigInteger key)
|
||||
{
|
||||
this.seq = new DerSequence(
|
||||
new DerInteger(1),
|
||||
new DerOctetString(key.ToByteArrayUnsigned()));
|
||||
}
|
||||
|
||||
public BigInteger GetKey()
|
||||
{
|
||||
Asn1OctetString octs = (Asn1OctetString) seq[1];
|
||||
|
||||
return new BigInteger(1, octs.GetOctets());
|
||||
}
|
||||
|
||||
public DerBitString GetPublicKey()
|
||||
{
|
||||
return (DerBitString) GetObjectInTag(1);
|
||||
}
|
||||
|
||||
public Asn1Object GetParameters()
|
||||
{
|
||||
return GetObjectInTag(0);
|
||||
}
|
||||
|
||||
private Asn1Object GetObjectInTag(
|
||||
int tagNo)
|
||||
{
|
||||
foreach (Asn1Encodable ae in seq)
|
||||
{
|
||||
Asn1Object obj = ae.ToAsn1Object();
|
||||
|
||||
if (obj is Asn1TaggedObject)
|
||||
{
|
||||
Asn1TaggedObject tag = (Asn1TaggedObject) obj;
|
||||
if (tag.TagNo == tagNo)
|
||||
{
|
||||
return tag.GetObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* ECPrivateKey ::= SEQUENCE {
|
||||
* version INTEGER { ecPrivkeyVer1(1) } (ecPrivkeyVer1),
|
||||
* privateKey OCTET STRING,
|
||||
* parameters [0] Parameters OPTIONAL,
|
||||
* publicKey [1] BIT STRING OPTIONAL }
|
||||
*/
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return seq;
|
||||
}
|
||||
}
|
||||
}
|
1191
iTechSharp/srcbc/asn1/sec/SECNamedCurves.cs
Normal file
1191
iTechSharp/srcbc/asn1/sec/SECNamedCurves.cs
Normal file
File diff suppressed because it is too large
Load Diff
52
iTechSharp/srcbc/asn1/sec/SECObjectIdentifiers.cs
Normal file
52
iTechSharp/srcbc/asn1/sec/SECObjectIdentifiers.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Asn1;
|
||||
using Org.BouncyCastle.Asn1.X9;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Sec
|
||||
{
|
||||
public abstract class SecObjectIdentifiers
|
||||
{
|
||||
/**
|
||||
* EllipticCurve OBJECT IDENTIFIER ::= {
|
||||
* iso(1) identified-organization(3) certicom(132) curve(0)
|
||||
* }
|
||||
*/
|
||||
public static readonly DerObjectIdentifier EllipticCurve = new DerObjectIdentifier("1.3.132.0");
|
||||
|
||||
public static readonly DerObjectIdentifier SecT163k1 = new DerObjectIdentifier(EllipticCurve + ".1");
|
||||
public static readonly DerObjectIdentifier SecT163r1 = new DerObjectIdentifier(EllipticCurve + ".2");
|
||||
public static readonly DerObjectIdentifier SecT239k1 = new DerObjectIdentifier(EllipticCurve + ".3");
|
||||
public static readonly DerObjectIdentifier SecT113r1 = new DerObjectIdentifier(EllipticCurve + ".4");
|
||||
public static readonly DerObjectIdentifier SecT113r2 = new DerObjectIdentifier(EllipticCurve + ".5");
|
||||
public static readonly DerObjectIdentifier SecP112r1 = new DerObjectIdentifier(EllipticCurve + ".6");
|
||||
public static readonly DerObjectIdentifier SecP112r2 = new DerObjectIdentifier(EllipticCurve + ".7");
|
||||
public static readonly DerObjectIdentifier SecP160r1 = new DerObjectIdentifier(EllipticCurve + ".8");
|
||||
public static readonly DerObjectIdentifier SecP160k1 = new DerObjectIdentifier(EllipticCurve + ".9");
|
||||
public static readonly DerObjectIdentifier SecP256k1 = new DerObjectIdentifier(EllipticCurve + ".10");
|
||||
public static readonly DerObjectIdentifier SecT163r2 = new DerObjectIdentifier(EllipticCurve + ".15");
|
||||
public static readonly DerObjectIdentifier SecT283k1 = new DerObjectIdentifier(EllipticCurve + ".16");
|
||||
public static readonly DerObjectIdentifier SecT283r1 = new DerObjectIdentifier(EllipticCurve + ".17");
|
||||
public static readonly DerObjectIdentifier SecT131r1 = new DerObjectIdentifier(EllipticCurve + ".22");
|
||||
public static readonly DerObjectIdentifier SecT131r2 = new DerObjectIdentifier(EllipticCurve + ".23");
|
||||
public static readonly DerObjectIdentifier SecT193r1 = new DerObjectIdentifier(EllipticCurve + ".24");
|
||||
public static readonly DerObjectIdentifier SecT193r2 = new DerObjectIdentifier(EllipticCurve + ".25");
|
||||
public static readonly DerObjectIdentifier SecT233k1 = new DerObjectIdentifier(EllipticCurve + ".26");
|
||||
public static readonly DerObjectIdentifier SecT233r1 = new DerObjectIdentifier(EllipticCurve + ".27");
|
||||
public static readonly DerObjectIdentifier SecP128r1 = new DerObjectIdentifier(EllipticCurve + ".28");
|
||||
public static readonly DerObjectIdentifier SecP128r2 = new DerObjectIdentifier(EllipticCurve + ".29");
|
||||
public static readonly DerObjectIdentifier SecP160r2 = new DerObjectIdentifier(EllipticCurve + ".30");
|
||||
public static readonly DerObjectIdentifier SecP192k1 = new DerObjectIdentifier(EllipticCurve + ".31");
|
||||
public static readonly DerObjectIdentifier SecP224k1 = new DerObjectIdentifier(EllipticCurve + ".32");
|
||||
public static readonly DerObjectIdentifier SecP224r1 = new DerObjectIdentifier(EllipticCurve + ".33");
|
||||
public static readonly DerObjectIdentifier SecP384r1 = new DerObjectIdentifier(EllipticCurve + ".34");
|
||||
public static readonly DerObjectIdentifier SecP521r1 = new DerObjectIdentifier(EllipticCurve + ".35");
|
||||
public static readonly DerObjectIdentifier SecT409k1 = new DerObjectIdentifier(EllipticCurve + ".36");
|
||||
public static readonly DerObjectIdentifier SecT409r1 = new DerObjectIdentifier(EllipticCurve + ".37");
|
||||
public static readonly DerObjectIdentifier SecT571k1 = new DerObjectIdentifier(EllipticCurve + ".38");
|
||||
public static readonly DerObjectIdentifier SecT571r1 = new DerObjectIdentifier(EllipticCurve + ".39");
|
||||
|
||||
public static readonly DerObjectIdentifier SecP192r1 = X9ObjectIdentifiers.Prime192v1;
|
||||
public static readonly DerObjectIdentifier SecP256r1 = X9ObjectIdentifiers.Prime256v1;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user