RIoT (DiceRIoTEmulator 1.0 API)
Date: 2017-11-08

com.microsoft.msr.RiotEmulator

## Class RIoT

- java.lang.Object
- - com.microsoft.msr.RiotEmulator.RIoT

-     public class RIoT
      extends Object

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `RIoT.DeviceAuthBundle` Container for PEM-encoded keys and certificates created by the RIoT Emulator

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RIoT()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static RIoT.DeviceAuthBundle` | `CreateDeviceAuthBundle(byte[] UDS, byte[] FWID, boolean createCSR)` The RIoT Emulator.
    `static RIoT.DeviceAuthBundle` | `CreateDeviceAuthBundle(byte[] UDS, byte[] FWID, boolean createCSR, String rCN, String dCN, String aCN)` The RIoT Emulator.
    `static void` | `CreateLeafCert(RIoT.DeviceAuthBundle devAuth, String commonName)` Create a certificate proving possession of the root key.
    `static KeyPair` | `DeriveEccKey(byte[] srcData)` Create an ECC key pair deterministically based on the provided source data
    `static byte[]` | `Hash(byte[] buf)` Hashing function for RIoT emulation (SHA256)
    `static byte[]` | `Hash(byte[] buf1, byte[] buf2)` Hash function for DICE emulation (SHA256)

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RIoT

          public RIoT()

  - ### Method Detail

    - #### CreateLeafCert

          public static void CreateLeafCert(RIoT.DeviceAuthBundle devAuth,
                                            String commonName)

      Create a certificate proving possession of the root key.
      Parameters:
        `devAuth` - An initialized DeviceAuthBundle containing DICE/RIoT keys and certs
        `commonName` - The "verifier" string from the DPS to be inserted in the cert's TBS data

    - #### CreateDeviceAuthBundle

          public static RIoT.DeviceAuthBundle CreateDeviceAuthBundle(byte[] UDS,
                                                                     byte[] FWID,
                                                                     boolean createCSR,
                                                                     String rCN,
                                                                     String dCN,
                                                                     String aCN)

      The RIoT Emulator. This takes a UDS value and a FWID and creates the resultant DeviceID and Alias Keys and Certificates.
      Parameters:
        `UDS` - The Unique Device Secret for this emulated "device"
        `FWID` - The Firmware ID (e.g., the measurement of the firmware image) on this emulated "device"
        `createCSR` - Indicates whether a Certificate Signing Request should be generated
        `rCN` - String to provide as Subject Common Name in "root" CA Key Certificate
        `dCN` - String to provide as Subject Common Name in DeviceID Key Certificate
        `aCN` - String to provide as Subject Common Name in Alias Key Certificate
      Returns:
        An instance of DeviceAuthBundle containing DeviceID and Alias Keys and Certificates

    - #### CreateDeviceAuthBundle

          public static RIoT.DeviceAuthBundle CreateDeviceAuthBundle(byte[] UDS,
                                                                     byte[] FWID,
                                                                     boolean createCSR)

      The RIoT Emulator. This takes a UDS value and a FWID and creates the resultant DeviceID and Alias Keys and Certificates.
      Parameters:
        `UDS` - The Unique Device Secret for this emulated "device"
        `FWID` - The Firmware ID (e.g., the measurement of the firmware image) on this emulated "device"
        `createCSR` - Indicates whether a Certificate Signing Request should be generated
      Returns:
        An instance of DeviceAuthBundle containing DeviceID and Alias Keys and Certificates

    - #### DeriveEccKey

          public static KeyPair DeriveEccKey(byte[] srcData)
                                      throws NoSuchAlgorithmException,
                                             NoSuchProviderException,
                                             InvalidAlgorithmParameterException

      Create an ECC key pair deterministically based on the provided source data
      Parameters:
        `srcData` - The seed for key derivation
      Returns:
        A new ECC key pair
      Throws:
        `NoSuchAlgorithmException` - Problem with rSignAlg
        `NoSuchProviderException` - Problem with BC provider
        `InvalidAlgorithmParameterException` - Problem with rEcCurve

    - #### Hash

          public static byte[] Hash(byte[] buf)
                             throws NoSuchAlgorithmException

      Hashing function for RIoT emulation (SHA256)
      Parameters:
        `buf` - Byte buffer from which digest is computed
      Returns:
        Digest of 'buf'
      Throws:
        `NoSuchAlgorithmException` - When no "SHA-256"

    - #### Hash

          public static byte[] Hash(byte[] buf1,
                                    byte[] buf2)
                             throws NoSuchAlgorithmException

      Hash function for DICE emulation (SHA256)
      Parameters:
        `buf1` - First byte buffer to be included in digest
        `buf2` - Second byte buffer to be included in digest
      Returns:
        Digest of 'buf1' and 'buf2'
      Throws:
        `NoSuchAlgorithmException` - When no "SHA-256"

Copyright © 2017. All rights reserved.