Subversion Repositories ESP8266_P1_Meter

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 raymond 1
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
 
15
#pragma once
16
 
17
#include <Arduino.h>
18
#if ESP_IDF_VERSION_MAJOR < 5
19
 
20
#include <Stream.h>
21
#include <WString.h>
22
 
23
#define SHA1_HASH_SIZE 20
24
 
25
class SHA1Builder {
26
private:
27
  uint32_t total[2];            /* number of bytes processed  */
28
  uint32_t state[5];            /* intermediate digest state  */
29
  unsigned char buffer[64];     /* data block being processed */
30
  uint8_t hash[SHA1_HASH_SIZE]; /* SHA-1 result               */
31
 
32
  void process(const uint8_t *data);
33
 
34
public:
35
  void begin();
36
  void add(const uint8_t *data, size_t len);
37
  void calculate();
38
  void getBytes(uint8_t *output);
39
};
40
 
41
#endif  // ESP_IDF_VERSION_MAJOR < 5