1 17 18 package org.apache.geronimo.util.asn1.sec; 19 20 import java.math.BigInteger ; 21 import org.apache.geronimo.util.asn1.*; 22 23 26 public class ECPrivateKeyStructure 27 extends ASN1Encodable 28 { 29 private ASN1Sequence seq; 30 31 public ECPrivateKeyStructure( 32 ASN1Sequence seq) 33 { 34 this.seq = seq; 35 } 36 37 public ECPrivateKeyStructure( 38 BigInteger key) 39 { 40 byte[] bytes = key.toByteArray(); 41 42 if (bytes[0] == 0) 43 { 44 byte[] tmp = new byte[bytes.length - 1]; 45 46 System.arraycopy(bytes, 1, tmp, 0, tmp.length); 47 bytes = tmp; 48 } 49 50 ASN1EncodableVector v = new ASN1EncodableVector(); 51 52 v.add(new DERInteger(1)); 53 v.add(new DEROctetString(bytes)); 54 55 seq = new DERSequence(v); 56 } 57 58 public BigInteger getKey() 59 { 60 ASN1OctetString octs = (ASN1OctetString)seq.getObjectAt(1); 61 62 BigInteger k = new BigInteger (1, octs.getOctets()); 63 64 return k; 65 } 66 67 public DERObject toASN1Object() 68 { 69 return seq; 70 } 71 } 72 | Popular Tags |