/// <summary> /// Packs parts into a single message body. /// </summary> /// <param name="length">Message length.</param> /// <param name="version">Message version.</param> /// <param name="header">Header.</param> /// <param name="parameters">Security parameters.</param> /// <param name="data">Scope data.</param> /// <returns>The <see cref="Sequence" /> object that represents the message body.</returns> public static Sequence PackMessage(byte[] length, VersionCode version, ISegment header, ISegment parameters, ISnmpData data) { if (header == null) { throw new ArgumentNullException(nameof(header)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } if (data == null) { throw new ArgumentNullException(nameof(data)); } ISnmpData[] items = new[] { new Integer32((int)version), header.GetData(version), parameters.GetData(version), data }; return(new Sequence(length, items)); }
internal static Sequence PackMessage(VersionCode version, ISegment header, SecurityParameters parameters, ISnmpData data) { if (header == null) { throw new ArgumentNullException("header"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } if (data == null) { throw new ArgumentNullException("data"); } ISnmpData[] items = new[] { new Integer32((int)version), header.GetData(version), parameters.GetData(version), data }; return(new Sequence(items)); }
internal static Sequence PackMessage(VersionCode version, ISegment header, ISegment parameters, ISnmpData scopeBytes, IPrivacyProvider privacy) { if (scopeBytes == null) { throw new ArgumentNullException("scopeBytes"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } if (header == null) { throw new ArgumentNullException("header"); } if (privacy == null) { throw new ArgumentNullException("privacy"); } ISnmpData[] collection = new ISnmpData[4] { new Integer32((int)version), header.GetData(version), parameters.GetData(version), scopeBytes, }; return new Sequence(collection); }
internal static Sequence PackMessage(VersionCode version, ISegment header, SecurityParameters parameters, ISegment scope, IPrivacyProvider privacy) { if (scope == null) { throw new ArgumentNullException("scope"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } if (header == null) { throw new ArgumentNullException("header"); } if (privacy == null) { throw new ArgumentNullException("privacy"); } ISnmpData[] collection = new ISnmpData[4] { new Integer32((int)version), header.GetData(version), parameters.GetData(version), privacy.Encrypt(scope.GetData(version), parameters) }; return(new Sequence(collection)); }
/// <summary> /// Computes the hash. /// </summary> /// <param name="provider">The authentication provider.</param> /// <param name="version">The version.</param> /// <param name="header">The header.</param> /// <param name="parameters">The parameters.</param> /// <param name="scope">The scope.</param> /// <param name="privacy">The privacy provider.</param> public static void ComputeHash( this IAuthenticationProvider provider, VersionCode version, Header header, SecurityParameters parameters, ISegment scope, IPrivacyProvider privacy) { if (provider == null) { throw new ArgumentNullException("provider"); } if (header == null) { throw new ArgumentNullException("header"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } if (scope == null) { throw new ArgumentNullException("scope"); } if (privacy == null) { throw new ArgumentNullException("privacy"); } if (provider is DefaultAuthenticationProvider) { return; } if (0 == (header.SecurityLevel & Levels.Authentication)) { return; } var scopeData = privacy.GetScopeData(header, parameters, scope.GetData(version)); parameters.AuthenticationParameters = provider.ComputeHash(version, header, parameters, scopeData, privacy, null); // replace the hash. }
/// <summary> /// Computes the hash. /// </summary> /// <param name="provider">The authentication provider.</param> /// <param name="version">The version.</param> /// <param name="header">The header.</param> /// <param name="parameters">The parameters.</param> /// <param name="scope">The scope.</param> /// <param name="privacy">The privacy provider.</param> public static void ComputeHash(this IAuthenticationProvider provider, VersionCode version, Header header, SecurityParameters parameters, ISegment scope, IPrivacyProvider privacy) { if (provider == null) { throw new ArgumentNullException("provider"); } if (header == null) { throw new ArgumentNullException("header"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } if (scope == null) { throw new ArgumentNullException("scope"); } if (privacy == null) { throw new ArgumentNullException("privacy"); } if (provider is DefaultAuthenticationProvider) { return; } if (0 == (header.SecurityLevel & Levels.Authentication)) { return; } var scopeData = privacy.GetScopeData(header, parameters, scope.GetData(version)); parameters.AuthenticationParameters = provider.ComputeHash(version, header, parameters, scopeData, privacy, null); // replace the hash. }
internal static Sequence PackMessage(byte[] length, VersionCode version, ISegment header, ISegment parameters, ISnmpData data) { if (header == null) { throw new ArgumentNullException("header"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } if (data == null) { throw new ArgumentNullException("data"); } var items = new[] { new Integer32((int)version), header.GetData(version), parameters.GetData(version), data }; return new Sequence(length, items); }