AdScore.Common 1.0.0

dotnet add package AdScore.Common --version 1.0.0
                    
NuGet\Install-Package AdScore.Common -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AdScore.Common" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AdScore.Common" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AdScore.Common" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AdScore.Common --version 1.0.0
                    
#r "nuget: AdScore.Common, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=AdScore.Common&version=1.0.0
                    
Install AdScore.Common as a Cake Addin
#tool nuget:?package=AdScore.Common&version=1.0.0
                    
Install AdScore.Common as a Cake Tool

dotnet-common

Software License

This library provides various utilities for parsing Adscore signatures v4 and v5, and virtually anything that might be useful for customers doing server-side integration with the service.

Compatibility

Supported Signature v5 algorithms

  1. v5_0200H - OpenSSL CBC, HTTP query
  2. v5_0200S - OpenSSL CBC, PHP serialize
  3. v5_0201H - OpenSSL GCM, HTTP query
  4. v5_0201S - OpenSSL GCM, PHP serialize
  5. v5_0101H - sodium secretbox, HTTP query
  6. v5_0101S - sodium secretbox, PHP serialize
  7. v5_0200J - OpenSSL CBC, JSON
  8. v5_0201J - OpenSSL GCM, JSON
  9. v5_0101J - sodium secretbox, JSON
  10. v5_0101M - sodium secretbox, msgpack
  11. v5_0200M - OpenSSL CBC, msgpack
  12. v5_0201M - OpenSSL GCM, msgpack

Not supported Signature v5 algorithms

  1. v5_0101I - sodium secretbox, igbinary
  2. v5_0200I - OpenSSL CBC, igbinary
  3. v5_0201I - OpenSSL GCM, igbinary

Install

.NET/.NET Core Framework compatible with .NET Standard 2.1 is required.

The easiest way to utilize the library is to attach it as a NuGet dependency:

AdScore.Common

Usage

V4 signature decryption

When zone's "Response signature algorithm" is set to "Hashing" or "Signing", it means that V4 signatures are in use. They provide basic means to check incoming traffic for being organic and valuable, but do not carry any additional information.

Here are a few quick examples on how to use the verifier. First import the library namespace:

using AdScore.Signature;
[...]

than you have several options of how to verify signatures:


    // Verify with base64 encoded key.
    // (No expiry parameter, the default expiry time for requestTime and signatureTime is 60s)
    Signature4VerificationResult result =
        Signature4Verifier.Verify(
            "BAYAXlNKGQFeU0oggAGBAcAAIAUdn1gbCBmA-u-kF--oUSuFw4B93piWC1Dn-D_1_6gywQAgEXCqgk2zPD6hWI1Y2rlrtV-21eIYBsms0odUEXNbRbA",
            "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36",
            "customer",
            "a2V5X25vbl9iYXNlNjRfZW5jb2RlZA==",
            "73.109.57.137");

    [..]

    // Verify with checking if expired and non base64 encoded key
    //
    // IF signatureTime + expiry > CurrentDateInSeconds
    // THEN result.IsExpired == true
    result =
        Signature4Verifier.Verify(
            "BAYAXlNKGQFeU0oggAGBAcAAIAUdn1gbCBmA-u-kF--oUSuFw4B93piWC1Dn-D_1_6gywQAgEXCqgk2zPD6hWI1Y2rlrtV-21eIYBsms0odUEXNbRbA",
            "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36",
            "customer",
            "key_non_base64_encoded",
            false, // notify that we use non encoded key
            60, // signature cant be older than 1 min 
            "73.109.57.137");
    [..]

    // Verify against number of ip4 and ip6 addresses
    //(No expiry parameter, the default expiry time for requestTime and signatureTime is 60s)
    result =
        Signature4Verifier.Verify(
            "BAYAXlNKGQFeU0oggAGBAcAAIAUdn1gbCBmA-u-kF--oUSuFw4B93piWC1Dn-D_1_6gywQAgEXCqgk2zPD6hWI1Y2rlrtV-21eIYBsms0odUEXNbRbA",
            "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36",
            "customer",
            "key_non_base64_encoded",
            false, // notify that we use non encoded key
                
             //Multiple ip addresses either from httpXForwardForIpAddresses and remoteIpAddresses header
            "73.109.57.137", "73.109.57.138", "73.109.57.139", "73.109.57.140", "0:0:0:0:0:ffff:4d73:55d3", "0:0:0:0:0:fffff:4d73:55d4", "0:0:0:0:0:fffff:4d73:55d5", "0:0:0:0:0:fffff:4d73:55d6");
    [..]

    // Verify against number of ip4 and ip6 addresses passed as an array
    String[] ipAddresses = {"73.109.57.137", "73.109.57.138", "73.109.57.139", "73.109.57.140", "0:0:0:0:0:ffff:4d73:55d3", "0:0:0:0:0:fffff:4d73:55d4", "0:0:0:0:0:fffff:4d73:55d5", "0:0:0:0:0:fffff:4d73:55d6"};
    result =
        Signature4Verifier.Verify(
            "BAYAXlNKGQFeU0oggAGBAcAAIAUdn1gbCBmA-u-kF--oUSuFw4B93piWC1Dn-D_1_6gywQAgEXCqgk2zPD6hWI1Y2rlrtV-21eIYBsms0odUEXNbRbA",
            "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36",
            "customer",
            "a2V5X25vbl9iYXNlNjRfZW5jb2RlZA==",
            360,  // signature cant be older than 5min
            ipAddresses);
    
    
    // result object will contain a non-null value in verdict field in case of success

V5 signature decryption

V5 is in fact an encrypted payload containing various metadata about the traffic. Its decryption does not rely on IP address nor User Agent string, so it is immune for environment changes usually preventing V4 to be even decoded. Judge result is also included in the payload, but client doing the integration can make its own decision basing on the metadata accompanying.

Zone has to be set explicitly to V5 signature, if you don't see the option, please contact support as we are rolling this mode on customer's demand. The format supports a wide variety of encryption and serialization methods, some of them are included in this repository, but it can be extended to fulfill specific needs.

It can be integrated in V4-compatible mode, not making use of any V5 features (see V4 verification):

using AdScore.Signature;

[...]

    Signature5VerificationResult result = Signature5Verifier.Verify(
        "BQO7AAAAAAAB8RAB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n6EqWhGAd6ocdQvsXS6KH6Q5FsTM6S5IJ4o4q9x7YN58css97WbFw5RffPNHNggU97sEqG4ZcPEwMo8yXNK6V03DJFgLBC2F7C16vzZNualajF92_wsJ5XgjzU7say5ucmDRtQA5IEisPz8jl9vuLL8quS-I-zsJA-MJh6QsowPoegk8Ur76kn0",
        "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36",
        "dj0lTcsmjDnDYPSL2+DQPN7QwirCQOlqnPhiXwusEM0=",
        ["176.103.168.60"]);
    );

The result field score only after a successful Verify() call. This is expected behavior, to preserve compliance with V4 behavior - the result is only valid when it's proven to belong to a visitor; in other case an exception will be thrown. For custom integrations not relying on built-in verification routines (usually more tolerant), the result is present also in result field, but it's then the integrator's reponsibility to ensure whether it's trusted or not. When desired validation is more strict than the built-in one, the verify() can be called first, and after that any additional verification may take place.

Note: V4 signature parser also holds the payload, but it does not contain any useful informations, only timestamps and signed strings; especially - it does not contain any Judge result value, it is derived from the signature via several hashing/verification approaches.

Integration

Any questions you have with custom integration, please contact our support@adscore.com. Please remember that we do require adequate technical knowledge in order to be able to help with the integration; there are other integration methods which do not require any, or require very little programming.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 124 11/4/2024