Skip to content

[API Proposal]: SVE AES: change arg names and types #131204

Description

@a74nh

The following was approved for SVE AES in #94423

namespace System.Runtime.Intrinsics.Arm;

/// VectorT Summary
public abstract class SveAes : AdvSimd /// Feature: FEAT_SVE_AES
{

  public static unsafe Vector<byte> InverseMixColumns(Vector<byte> value); // AESIMC

  public static unsafe Vector<byte> MixColumns(Vector<byte> value); // AESMC

  public static unsafe Vector<byte> Decrypt(Vector<byte> left, Vector<byte> right); // AESD

  public static unsafe Vector<byte> Encrypt(Vector<byte> left, Vector<byte> right); // AESE

  public static unsafe Vector<ulong> PolynomialMultiplyWideningEven(Vector<ulong> left, Vector<ulong> right); // PMULLB

  public static unsafe Vector<ulong> PolynomialMultiplyWideningOdd(Vector<ulong> left, Vector<ulong> right); // PMULLT
}
  /// total method signatures: 6

There are three issues with these APIs

1:
The APIs do no need to be marked unsafe

2:
The names of the Decrypt/Encrypt arguments should be changed to match the existing Advsimd AES APIs:

  public static Vector<byte> Decrypt(Vector<byte> value, Vector<byte> roundKey); // AESD
  public static Vector<byte> Encrypt(Vector<byte> value, Vector<byte> roundKey); // AESE

3:
The argument types for the Polynomial functions are wrong. The forms of the instructions are:

PMULLB Zresult.H, Zop1.B, Zop2.B
PMULLB Zresult.D, Zop1.S, Zop2.S
PMULLT Zresult.H, Zop1.B, Zop2.B
PMULLT Zresult.D, Zop1.S, Zop2.S

Therefore the APIs should be:

public static Vector<ushort> PolynomialMultiplyWideningEven(Vector<byte> left, Vector<byte> right)
public static Vector<ulong> PolynomialMultiplyWideningEven(Vector<uint> left, Vector<uint> right)
public static Vector<ushort> PolynomialMultiplyWideningOdd(Vector<byte> left, Vector<byte> right)
public static Vector<ulong> PolynomialMultiplyWideningOdd(Vector<uint> left, Vector<uint> right)

These changes have been made in the implementation in #130859


The final suggested API is:

namespace System.Runtime.Intrinsics.Arm;

/// VectorT Summary
public abstract class SveAes : AdvSimd /// Feature: FEAT_SVE_AES
{

  public static Vector<byte> InverseMixColumns(Vector<byte> value); // AESIMC

  public static Vector<byte> MixColumns(Vector<byte> value); // AESMC

  public static Vector<byte> Decrypt(Vector<byte> value, Vector<byte> roundKey); // AESD

  public static Vector<byte> Encrypt(Vector<byte> value, Vector<byte> roundKey); // AESE

  public static Vector<ushort> PolynomialMultiplyWideningEven(Vector<byte> left, Vector<byte> right); // PMULLB

  public static Vector<ulong> PolynomialMultiplyWideningEven(Vector<uint> left, Vector<uint> right); // PMULLB

  public static Vector<ushort> PolynomialMultiplyWideningOdd(Vector<byte> left, Vector<byte> right); // PMULLT

  public static Vector<ulong> PolynomialMultiplyWideningOdd(Vector<uint> left, Vector<uint> right); // PMULLT

}
  /// total method signatures: 8

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions