GoogleCloudPlatform / google-cloud-iot-arduino

Google Cloud IOT Example on ESP8266
Apache License 2.0
351 stars 157 forks source link

Narrowing conversion of '2024104815l' from 'long int' to 'WORD #215

Open JuniorEC opened 3 years ago

JuniorEC commented 3 years ago

I'm trying to use the library with TinyGsm and I'm taking this strange error when I compile

Board: Arduino Mega 2560

Code:

#include <Wire.h>

#include <time.h>
#include <Arduino.h>

#include <MQTT.h>

#include <CloudIoTCore.h>
#include <CloudIoTCoreMqtt.h>
#include "ciotc_config.h" // Wifi configuration here

#define TINY_GSM_MODEM_SIM800
#include <TinyGsmClient.h>
#include <SoftwareSerial.h>

#define SerialMon Serial
#define GSM_AUTOBAUD_MIN 9600
#define GSM_AUTOBAUD_MAX 9600
#define TINY_GSM_USE_GPRS true
#define TINY_GSM_USE_WIFI false
///////////////////////////////
const char apn[] = "internet";
const char gprsUser[] = "";
const char gprsPass[] = "";
SoftwareSerial SerialAT(10, 11); // RX, TX
TinyGsm modem(SerialAT);
TinyGsmClientSecure *gsmclient;

// Initialize WiFi and MQTT for this board
MQTTClient *mqttClient;
// BearSSL::WiFiClientSecure *netClient;

CloudIoTCoreDevice *device;
CloudIoTCoreMqtt *mqtt;
unsigned long iat = 0;
String jwt;

String getJwt()
{
  // Disable software watchdog as these operations can take a while.
  // ESP.wdtDisable();
  iat = time(nullptr);
  Serial.println("Refreshing JWT");
  jwt = device->createJWT(iat, jwt_exp_secs);
  // ESP.wdtEnable(0);
  return jwt;
}

void connect()
{
  mqtt->mqttConnect();
}

// TODO: fix globals
void setupCloudIoT()
{
  // Create the device
  device = new CloudIoTCoreDevice(
      project_id, location, registry_id, device_id,
      private_key_str);

  // ESP8266 WiFi setup
  //gsmclient = gsmclient(modem);
  gsmclient = new TinyGsmClientSecure(modem);

  // setupWifi();

  // ESP8266 WiFi secure initialization
  // setupCert();

  mqttClient = new MQTTClient(512);
  mqttClient->setOptions(180, true, 1000); // keepAlive, cleanSession, timeout
  mqtt = new CloudIoTCoreMqtt(mqttClient, gsmclient, device);
  mqtt->setLogConnect(false); // If mqtt registry state ever connected on cloudiot core
  mqtt->setUseLts(true);      // Long-term service for MQTT

  mqtt->startMQTT(); // Opens connection
}

Log

Processing megaatmega2560 (platform: atmelavr; board: megaatmega2560; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/megaatmega2560.html
PLATFORM: Atmel AVR (3.1.0) > Arduino Mega or Mega 2560 ATmega2560 (Mega 2560)
HARDWARE: ATMEGA2560 16MHz, 8KB RAM, 248KB Flash
DEBUG: Current (avr-stub) On-board (avr-stub, simavr)
PACKAGES:
 - framework-arduino-avr 5.1.0
 - toolchain-atmelavr 1.50400.190710 (5.4.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 11 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <ArduinoJson> 6.17.2
|-- <MQTT> 2.4.8
|-- <Google Cloud IoT Core JWT> 1.1.11
|   |-- <MQTT> 2.4.8
|-- <TinyGSM> 0.10.9
|-- <SoftwareSerial> 1.0.0
|-- <PubSubClient> 2.8.0
|-- <Wire> 1.0
Building in release mode
Compiling .pio\build\megaatmega2560\lib5ae\Google Cloud IoT Core JWT\crypto\sha256.cpp.o
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '1116352408l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
 };
 ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '1899447441l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '3049323471ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '3921009573ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '961987163l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '1508970993l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '2453635748ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '2870763221ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '3624381080ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '310598401l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '607225278l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '1426881987l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '1925078388l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '2162078206ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '2614888103ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '3248222580ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '3835390401ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '4022224774ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '264347078l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '604807628l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '770255983l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '1249150122l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '1555081692l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '1996064986l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '2554220882ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '2821834349ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '2952996808ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '3210313671ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '3336571891ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '3584528711ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '113926993l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '338241895l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '666307205l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '773529912l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '1294757372l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '1396182291l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '1695183700l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '1986661051l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '2177026350ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '2456956037ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '2730485921ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '2820302411ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '3259730800ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '3345764771ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '3516065817ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '3600352804ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '4094571909ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '275423344l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '430227734l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '506948616l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '659060556l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '883997877l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '958139571l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '1322822218l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '1537002063l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '1747873779l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '1955562222l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '2024104815l' from 'long int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '2227730452ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '2361852424ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '2428436474ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '2756734187ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '3204031479ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:45:1: error: narrowing conversion of '3329325298ul' from 'long unsigned int' to 'WORD {aka unsigned int}' inside { } [-Wnarrowing]
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp: In constructor 'Sha256::Sha256()':
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:51:20: warning: large integer implicitly truncated to unsigned type [-Woverflow]
     this->state[0] = 0x6a09e667;
                    ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:52:20: warning: large integer implicitly truncated to unsigned type [-Woverflow]
     this->state[1] = 0xbb67ae85;
                    ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:53:20: warning: large integer implicitly truncated to unsigned type [-Woverflow]
     this->state[2] = 0x3c6ef372;
                    ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:54:20: warning: large integer implicitly truncated to unsigned type [-Woverflow]
     this->state[3] = 0xa54ff53a;
                    ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:55:20: warning: large integer implicitly truncated to unsigned type [-Woverflow]
     this->state[4] = 0x510e527f;
                    ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:56:20: warning: large integer implicitly truncated to unsigned type [-Woverflow]
     this->state[5] = 0x9b05688c;
                    ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:57:20: warning: large integer implicitly truncated to unsigned type [-Woverflow]
     this->state[6] = 0x1f83d9ab;
                    ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:58:20: warning: large integer implicitly truncated to unsigned type [-Woverflow]
     this->state[7] = 0x5be0cd19;
                    ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp: In member function 'void Sha256::transform()':
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:123:27: warning: left shift count >= width of type [-Wshift-count-overflow]
  m[i] = (this->data[j] << 24) | (this->data[j + 1] << 16) | (this->data[j + 2] << 8) | (this->data[j + 3]);
                           ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:123:55: warning: left shift count >= width of type [-Wshift-count-overflow]
  m[i] = (this->data[j] << 24) | (this->data[j + 1] << 16) | (this->data[j + 2] << 8) | (this->data[j + 3]);
                                                       ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:26:34: warning: right shift count >= width of type [-Wshift-count-overflow]
 #define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b))))
                                  ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:33:18: note: in expansion of macro 'ROTRIGHT'
 #define SIG1(x) (ROTRIGHT(x,17) ^ ROTRIGHT(x,19) ^ ((x) >> 10))
                  ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:125:9: note: in expansion of macro 'SIG1'
  m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
         ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:26:34: warning: right shift count >= width of type [-Wshift-count-overflow]
 #define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b))))
                                  ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:33:35: note: in expansion of macro 'ROTRIGHT'
 #define SIG1(x) (ROTRIGHT(x,17) ^ ROTRIGHT(x,19) ^ ((x) >> 10))
                                   ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:125:9: note: in expansion of macro 'SIG1'
  m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
         ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:26:54: warning: left shift count >= width of type [-Wshift-count-overflow]
 #define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b))))
                                                      ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:32:18: note: in expansion of macro 'ROTRIGHT'
 #define SIG0(x) (ROTRIGHT(x,7) ^ ROTRIGHT(x,18) ^ ((x) >> 3))
                  ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:125:37: note: in expansion of macro 'SIG0'
  m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
                                     ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:26:34: warning: right shift count >= width of type [-Wshift-count-overflow]
 #define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b))))
                                  ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:32:34: note: in expansion of macro 'ROTRIGHT'
 #define SIG0(x) (ROTRIGHT(x,7) ^ ROTRIGHT(x,18) ^ ((x) >> 3))
                                  ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:125:37: note: in expansion of macro 'SIG0'
  m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
                                     ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:26:54: warning: left shift count >= width of type [-Wshift-count-overflow]
 #define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b))))
                                                      ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:31:17: note: in expansion of macro 'ROTRIGHT'
 #define EP1(x) (ROTRIGHT(x,6) ^ ROTRIGHT(x,11) ^ ROTRIGHT(x,25))
                 ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:137:11: note: in expansion of macro 'EP1'
  t1 = h + EP1(e) + CH(e,f,g) + k[i] + m[i];
           ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:26:54: warning: left shift count >= width of type [-Wshift-count-overflow]
 #define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b))))
                                                      ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:31:33: note: in expansion of macro 'ROTRIGHT'
 #define EP1(x) (ROTRIGHT(x,6) ^ ROTRIGHT(x,11) ^ ROTRIGHT(x,25))
                                 ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:137:11: note: in expansion of macro 'EP1'
  t1 = h + EP1(e) + CH(e,f,g) + k[i] + m[i];
           ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:26:34: warning: right shift count >= width of type [-Wshift-count-overflow]
 #define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b))))
                                  ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:31:50: note: in expansion of macro 'ROTRIGHT'
 #define EP1(x) (ROTRIGHT(x,6) ^ ROTRIGHT(x,11) ^ ROTRIGHT(x,25))
                                                  ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:137:11: note: in expansion of macro 'EP1'
  t1 = h + EP1(e) + CH(e,f,g) + k[i] + m[i];
           ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:26:54: warning: left shift count >= width of type [-Wshift-count-overflow]
 #define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b))))
                                                      ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:30:17: note: in expansion of macro 'ROTRIGHT'
 #define EP0(x) (ROTRIGHT(x,2) ^ ROTRIGHT(x,13) ^ ROTRIGHT(x,22))
                 ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:138:7: note: in expansion of macro 'EP0'
  t2 = EP0(a) + MAJ(a,b,c);
       ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:26:54: warning: left shift count >= width of type [-Wshift-count-overflow]
 #define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b))))
                                                      ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:30:33: note: in expansion of macro 'ROTRIGHT'
 #define EP0(x) (ROTRIGHT(x,2) ^ ROTRIGHT(x,13) ^ ROTRIGHT(x,22))
                                 ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:138:7: note: in expansion of macro 'EP0'
  t2 = EP0(a) + MAJ(a,b,c);
       ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:26:34: warning: right shift count >= width of type [-Wshift-count-overflow]
 #define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b))))
                                  ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:30:50: note: in expansion of macro 'ROTRIGHT'
 #define EP0(x) (ROTRIGHT(x,2) ^ ROTRIGHT(x,13) ^ ROTRIGHT(x,22))
                                                  ^
.pio\libdeps\megaatmega2560\Google Cloud IoT Core JWT\src\crypto\sha256.cpp:138:7: note: in expansion of macro 'EP0'
  t2 = EP0(a) + MAJ(a,b,c);
       ^
*** [.pio\build\megaatmega2560\lib5ae\Google Cloud IoT Core JWT\crypto\sha256.cpp.o] Error 1
SamGeens commented 3 years ago

Hi

Have you found the solution for your problem yet?

I'm trying to use this library just like you on an Arduino mega 2560 but I'm using WifiESP with a ESP8266 shield. I'm able to make a wifi connection but I'm having problems with generating the JWT token. I've been debugging for a while now and it seems that the JWT generation isn't working because of the public key is loaded in static BearSSL::X509List certList; which you removed aswell from the code. This might be the (one of the) explaination(s) for your error.

It might be that this library would be able to generate ES256 jwt tokens on AVR architecture with some minor changes. Anyone who can help with this?

gguuss commented 3 years ago

It might be that this library would be able to generate ES256 jwt tokens on AVR architecture with some minor changes. Anyone who can help with this?

I'm able to give some limited support but am not actively developing the library. If you need code review and change verification, happy to review and test PRs.

SamGeens commented 3 years ago

I've made some small changes to make the library run on arduino uno and mega. But when generating the JWT token it gets stuck in an endless loop on AVR architecture. The problem is in ecc_win_mul in ecc.cpp when generating the public key.