/* Convert a nonnegative integer to an octet string of a specified length. */
EFI_STATUS EFIAPI Int2OctStr(IN CONST UINTN *Integer, IN UINTN IntSizeInWords, OUT UINT8 *OctetString, IN UINTN OSSizeInBytes)
/* Convert a nonnegative integer to an octet string of a specified length. */
EFI_STATUS EFIAPI Int2OctStr(IN CONST UINTN *Integer, IN UINTN IntSizeInWords, OUT UINT8 *OctetString, IN UINTN OSSizeInBytes)
{
  CONST UINT8  *Ptr1;
  UINT8        *Ptr2;
  for (Ptr1 = (CONST UINT8 *)Integer, Ptr2 = OctetString + OSSizeInBytes - 1;
       Ptr1 < (UINT8 *)(Integer + IntSizeInWords) && Ptr2 >= OctetString;
       Ptr1++, Ptr2--)
  {
    *Ptr2 = *Ptr1;
  }
  for ( ; Ptr1 < (CONST UINT8 *)(Integer + IntSizeInWords) && *Ptr1 == 0; Ptr1++) {
  }
  if (Ptr1 < (CONST UINT8 *)(Integer + IntSizeInWords)) {
    return EFI_BUFFER_TOO_SMALL;
  }
  if (Ptr2 >= OctetString) {
    ZeroMem (OctetString, Ptr2 - OctetString + 1);
  }
  return EFI_SUCCESS;
}