/// <summary> /// Creates a new instance of the TKeyRecord class /// </summary> /// <param name="name"> Name of the record </param> /// <param name="algorithm"> Algorithm of the key </param> /// <param name="inception"> Date from which the key is valid </param> /// <param name="expiration"> Date to which the key is valid </param> /// <param name="mode"> Mode of transaction </param> /// <param name="error"> Error field </param> /// <param name="key"> Binary data of the key </param> /// <param name="otherData"> Binary other data </param> public TKeyRecord(DomainName name, TSigAlgorithm algorithm, DateTime inception, DateTime expiration, TKeyMode mode, ReturnCode error, byte[] key, byte[] otherData) : base(name, RecordType.TKey, RecordClass.Any, 0) { Algorithm = algorithm; Inception = inception; Expiration = expiration; Mode = mode; Error = error; Key = key ?? new byte[] { }; OtherData = otherData ?? new byte[] { }; }
public TKeyRecord(string name, TSigAlgorithm algorithm, DateTime inception, DateTime expiration, TKeyMode mode, ReturnCode error, byte[] key, byte[] otherData) : base(name, RecordType.TKey, RecordClass.Any, 0) { Algorithm = algorithm; Inception = inception; Expiration = expiration; Mode = mode; Error = error; Key = key ?? new byte[] { }; OtherData = otherData ?? new byte[] { }; }
/// <summary> /// Creates a new instance of the TSigRecord class /// </summary> /// <param name="name"> Name of the record </param> /// <param name="algorithm"> Algorithm of the key </param> /// <param name="timeSigned"> Time when the data was signed </param> /// <param name="fudge"> Timespan errors permitted </param> /// <param name="originalID"> Original ID of message </param> /// <param name="error"> Error field </param> /// <param name="otherData"> Binary other data </param> /// <param name="keyData"> Binary data of the key </param> public TSigRecord(DomainName name, TSigAlgorithm algorithm, DateTime timeSigned, TimeSpan fudge, ushort originalID, ReturnCode error, byte[] otherData, byte[] keyData) : base(name, RecordType.TSig, RecordClass.Any, 0) { Algorithm = algorithm; TimeSigned = timeSigned; Fudge = fudge; Mac = new byte[] { }; OriginalID = originalID; Error = error; OtherData = otherData ?? new byte[] { }; KeyData = keyData; }
public TSigRecord(string name, TSigAlgorithm algorithm, DateTime timeSigned, TimeSpan fudge, ushort originalID, ReturnCode error, byte[] otherData, byte[] keyData) : base(name, RecordType.TSig, RecordClass.Any, 0) { Algorithm = algorithm; TimeSigned = timeSigned; Fudge = fudge; OriginalMac = new byte[] { }; OriginalID = originalID; Error = error; OtherData = otherData ?? new byte[] { }; KeyData = keyData; }
public override void setTSIGKey(String name, TSigAlgorithm algorithm, String key) { if (name != null && key != null) { this.tsigName = DomainName.Parse(name); this.tsigAlg = algorithm; this.tsigKey = Convert.FromBase64String(key); // TSigRecord // this.tsigKey = System.Text.UTF8Encoding.ASCII.GetBytes(key); } }
// Public methods. /// <summary> /// Gets the domain name of the specified algorithm. /// </summary> /// <param name="algorithm">The algorithm.</param> /// <returns>The domain name.</returns> public static string GetDomainName(TSigAlgorithm algorithm) { switch (algorithm) { case TSigAlgorithm.Md5: return "hmac-md5.sig-alg.reg.int"; case TSigAlgorithm.Sha1: return "hmac-sha1"; case TSigAlgorithm.Sha256: return "hmac-sha256"; case TSigAlgorithm.Sha384: return "hmac-sha384"; case TSigAlgorithm.Sha512: return "hmac-sha512"; default: return null; } }
public static KeyedHashAlgorithm GetHashAlgorithm(TSigAlgorithm algorithm) { switch (algorithm) { case TSigAlgorithm.Md5: return new HMACMD5(); case TSigAlgorithm.Sha1: return new HMACSHA1(); case TSigAlgorithm.Sha256: return new HMACSHA256(); case TSigAlgorithm.Sha384: return new HMACSHA384(); case TSigAlgorithm.Sha512: return new HMACSHA512(); default: return null; } }
internal static int GetHashSize(TSigAlgorithm algorithm) { switch (algorithm) { case TSigAlgorithm.Md5: return 16; case TSigAlgorithm.Sha1: return 20; case TSigAlgorithm.Sha256: return 32; case TSigAlgorithm.Sha384: return 48; case TSigAlgorithm.Sha512: return 64; default: return 0; } }
public static DomainName GetDomainName(TSigAlgorithm algorithm) { switch (algorithm) { case TSigAlgorithm.Md5: return DomainName.Parse("hmac-md5.sig-alg.reg.int"); case TSigAlgorithm.Sha1: return DomainName.Parse("hmac-sha1"); case TSigAlgorithm.Sha256: return DomainName.Parse("hmac-sha256"); case TSigAlgorithm.Sha384: return DomainName.Parse("hmac-sha384"); case TSigAlgorithm.Sha512: return DomainName.Parse("hmac-sha512"); default: return null; } }
public static KeyedHashAlgorithm GetHashAlgorithm(TSigAlgorithm algorithm) { switch (algorithm) { case TSigAlgorithm.Md5: return(new HMACMD5()); case TSigAlgorithm.Sha1: return(new HMACSHA1()); case TSigAlgorithm.Sha256: return(new HMACSHA256()); case TSigAlgorithm.Sha384: return(new HMACSHA384()); case TSigAlgorithm.Sha512: return(new HMACSHA512()); default: return(null); } }
public static DomainName GetDomainName(TSigAlgorithm algorithm) { switch (algorithm) { case TSigAlgorithm.Md5: return(DomainName.Parse("hmac-md5.sig-alg.reg.int")); case TSigAlgorithm.Sha1: return(DomainName.Parse("hmac-sha1")); case TSigAlgorithm.Sha256: return(DomainName.Parse("hmac-sha256")); case TSigAlgorithm.Sha384: return(DomainName.Parse("hmac-sha384")); case TSigAlgorithm.Sha512: return(DomainName.Parse("hmac-sha512")); default: return(null); } }
internal static int GetHashSize(TSigAlgorithm algorithm) { switch (algorithm) { case TSigAlgorithm.Md5: return(16); case TSigAlgorithm.Sha1: return(20); case TSigAlgorithm.Sha256: return(32); case TSigAlgorithm.Sha384: return(48); case TSigAlgorithm.Sha512: return(64); default: return(0); } }
/** * Set the TSIG key used to authenticate updates sent to the DNS server. * Passing null for all values to disable TSIG authentication. * @param name the name of the key. * @param algorithm the signature algorithm, one of {@link #TSIG_ALGORITHM_HMAC_MD5}, * {@link #TSIG_ALGORITHM_HMAC_SHA1}, {@link #TSIG_ALGORITHM_HMAC_SHA256} * @param key the base64 encoded key. */ public abstract void setTSIGKey(String name, TSigAlgorithm algorithm, String key);