internal override byte[] GenerateBytes() { var builder = new FlatBufferBuilder(1); var signer = SignatureTransactionBuffer.CreatePublicKeyVector(builder, GetSigner()); var hash = SignatureTransactionBuffer.CreateHashVector(builder, OtherHash.FromHex()); var address = SignatureTransactionBuffer.CreateMultisigAddressVector(builder, Encoding.UTF8.GetBytes(MultisigAddress.Plain)); SignatureTransactionBuffer.StartSignatureTransactionBuffer(builder); SignatureTransactionBuffer.AddTransactionType(builder, TransactionType.GetValue()); SignatureTransactionBuffer.AddVersion(builder, BitConverter.ToInt16(new byte[] { ExtractVersion(Version), 0 }, 0)); SignatureTransactionBuffer.AddNetwork(builder, BitConverter.ToInt16(new byte[] { 0, NetworkType.GetNetwork() }, 0)); SignatureTransactionBuffer.AddTimestamp(builder, NetworkTime.EpochTimeInMilliSeconds()); SignatureTransactionBuffer.AddPublicKeyLen(builder, 32); SignatureTransactionBuffer.AddPublicKey(builder, signer); SignatureTransactionBuffer.AddFee(builder, Fee); SignatureTransactionBuffer.AddDeadline(builder, Deadline.Ticks); SignatureTransactionBuffer.AddHashObjLength(builder, 0x24); SignatureTransactionBuffer.AddSha3HashLength(builder, 0x20); SignatureTransactionBuffer.AddHash(builder, hash); SignatureTransactionBuffer.AddAddressLength(builder, 0x28); SignatureTransactionBuffer.AddMultisigAddress(builder, address); var result = SignatureTransactionBuffer.EndSignatureTransactionBuffer(builder); builder.Finish(result.Value); return(new SignatureTransactionSchema().Serialize(builder.SizedByteArray())); }
public override void PerformTest() { AlgorithmIdentifier algId = new AlgorithmIdentifier(new DerObjectIdentifier("1.2.2.3")); byte[] digest = new byte[20]; OtherHash otherHash = new OtherHash(new OtherHashAlgAndValue(algId, digest)); IssuerSerial issuerSerial = new IssuerSerial(new GeneralNames(new GeneralName(new X509Name("CN=test"))), new DerInteger(1)); OtherCertID certID = new OtherCertID(otherHash); checkConstruction(certID, algId, digest, null); certID = new OtherCertID(otherHash, issuerSerial); checkConstruction(certID, algId, digest, issuerSerial); certID = OtherCertID.GetInstance(null); if (certID != null) { Fail("null GetInstance() failed."); } try { OtherCertID.GetInstance(new Object()); Fail("GetInstance() failed to detect bad object."); } catch (ArgumentException) { // expected } }
public override void PerformTest() { AlgorithmIdentifier algId = new AlgorithmIdentifier(new DerObjectIdentifier("1.2.2.3")); byte[] digest = new byte[20]; OtherHash otherHash = new OtherHash( new OtherHashAlgAndValue(algId, digest)); OtherCertID otherCertID = new OtherCertID(otherHash); OtherSigningCertificate otherCert = new OtherSigningCertificate(otherCertID); checkConstruction(otherCert, otherCertID); otherCert = OtherSigningCertificate.GetInstance(null); if (otherCert != null) { Fail("null GetInstance() failed."); } try { OtherCertID.GetInstance(new Object()); Fail("GetInstance() failed to detect bad object."); } catch (ArgumentException) { // expected } }
/// <summary>Create a reference to a X509Crl</summary> /// <param name="crl"></param> /// <returns></returns> /// <exception cref="Sharpen.NoSuchAlgorithmException">Sharpen.NoSuchAlgorithmException /// </exception> /// <exception cref="Sharpen.CrlException">Sharpen.CrlException</exception> private CrlValidatedID MakeCrlValidatedID(X509Crl crl) { OtherHash hash = new OtherHash(DigestUtilities.CalculateDigest (X509ObjectIdentifiers.IdSha1, crl.GetEncoded())); BigInteger crlnumber; CrlIdentifier crlid; DerObjectIdentifier crlExt = new DerObjectIdentifier("2.5.29.20"); if (crl.GetExtensionValue(crlExt) != null) { //crlnumber = new DerInteger(crl.GetExtensionValue(crlExt)).GetPositiveValue(); crlnumber = new DerInteger(crl.GetExtensionValue(crlExt).GetDerEncoded()).PositiveValue; //crlid = new CrlIdentifier(new X509Name(crl.IssuerDN.GetName()), new crlid = new CrlIdentifier(crl.IssuerDN, //new DerUtcTime(crl.ThisUpdate), crlnumber); crl.ThisUpdate, crlnumber); } else { //crlid = new CrlIdentifier(new X509Name(crl.IssuerDN.GetName()), crlid = new CrlIdentifier(crl.IssuerDN, //new DerUtcTime(crl.ThisUpdate)); crl.ThisUpdate); } CrlValidatedID crlvid = new CrlValidatedID(hash, crlid); return(crlvid); }
public CrlValidatedID(OtherHash crlHash, CrlIdentifier crlIdentifier) { if (crlHash == null) { throw new ArgumentNullException("crlHash"); } this.crlHash = crlHash; this.crlIdentifier = crlIdentifier; }
public OcspResponsesID(OcspIdentifier ocspIdentifier, OtherHash ocspRepHash) { if (ocspIdentifier == null) { throw new ArgumentNullException("ocspIdentifier"); } this.ocspIdentifier = ocspIdentifier; this.ocspRepHash = ocspRepHash; }
public OtherCertID(OtherHash otherCertHash, IssuerSerial issuerSerial) { if (otherCertHash == null) { throw new ArgumentNullException("otherCertHash"); } this.otherCertHash = otherCertHash; this.issuerSerial = issuerSerial; }
/// <summary> /// Create a reference to a X509Certificate /// </summary> private static OtherCertID MakeOtherCertID(X509Certificate cert) { byte[] d = DigestUtilities.CalculateDigest(X509ObjectIdentifiers.IdSha1, cert.GetEncoded()); logger.Info(new DerOctetString(d).ToString()); OtherHash hash = new OtherHash(d); OtherCertID othercertid = new OtherCertID(hash); return(othercertid); }
/// <summary>Create a reference to a X509Certificate</summary> /// <param name="cert"></param> /// <returns></returns> /// <exception cref="Sharpen.NoSuchAlgorithmException">Sharpen.NoSuchAlgorithmException /// </exception> /// <exception cref="Sharpen.CertificateEncodingException">Sharpen.CertificateEncodingException /// </exception> private OtherCertID MakeOtherCertID(X509Certificate cert) { byte[] d = DigestUtilities.CalculateDigest (X509ObjectIdentifiers.IdSha1, cert.GetEncoded()); //LOG.Info(new DerOctetString(d).ToString()); OtherHash hash = new OtherHash(d); //OtherCertID othercertid = new OtherCertID(new DerSequence(hash.ToAsn1Object())); OtherCertID othercertid = new OtherCertID(hash); return(othercertid); }
/// <summary> /// Create a reference on a OcspResp /// </summary> private static OcspResponsesID MakeOcspResponsesID(BasicOcspResp ocspResp) { byte[] digestValue = DigestUtilities.CalculateDigest (X509ObjectIdentifiers.IdSha1, ocspResp.GetEncoded()); OtherHash hash = new OtherHash(digestValue); OcspResponsesID ocsprespid = new OcspResponsesID(new OcspIdentifier(ocspResp.ResponderId .ToAsn1Object(), ocspResp.ProducedAt), hash); logger.Info("Incorporate OcspResponseId[hash=" + Hex.ToHexString(digestValue) + ",producedAt=" + ocspResp.ProducedAt); return(ocsprespid); }
private CrlValidatedID(Asn1Sequence seq) { if (seq == null) { throw new ArgumentNullException("seq"); } if (seq.Count < 1 || seq.Count > 2) { throw new ArgumentException("Bad sequence size: " + seq.Count, "seq"); } crlHash = OtherHash.GetInstance(seq[0].ToAsn1Object()); if (seq.Count > 1) { crlIdentifier = CrlIdentifier.GetInstance(seq[1].ToAsn1Object()); } }
private OtherCertID(Asn1Sequence seq) { if (seq == null) { throw new ArgumentNullException("seq"); } if (seq.Count < 1 || seq.Count > 2) { throw new ArgumentException("Bad sequence size: " + seq.Count, "seq"); } otherCertHash = OtherHash.GetInstance(seq[0].ToAsn1Object()); if (seq.Count > 1) { issuerSerial = IssuerSerial.GetInstance(seq[1].ToAsn1Object()); } }
private OcspResponsesID(Asn1Sequence seq) { if (seq == null) { throw new ArgumentNullException("seq"); } if (seq.Count < 1 || seq.Count > 2) { throw new ArgumentException("Bad sequence size: " + seq.Count, "seq"); } ocspIdentifier = OcspIdentifier.GetInstance(seq[0].ToAsn1Object()); if (seq.Count > 1) { ocspRepHash = OtherHash.GetInstance(seq[1].ToAsn1Object()); } }
public CrlValidatedID(OtherHash crlHash) : this(crlHash, null) { }
public OtherCertID(OtherHash otherCertHash) : this(otherCertHash, null) { }