Formatting

This commit is contained in:
Maschell 2021-10-17 15:28:14 +02:00
parent 80110c3f4c
commit f972091f50
9 changed files with 206 additions and 194 deletions

View File

@ -203,8 +203,7 @@ std::optional<uint64_t> InstallerService::getSystemMenuTitleId() {
if ((titleList->titleId != 0x0005001010040000L) &&
(titleList->titleId != 0x0005001010040100L) &&
(titleList->titleId != 0x0005001010040200L))
{
(titleList->titleId != 0x0005001010040200L)) {
DEBUG_FUNCTION_LINE("Unrecognized System Menu title");
return {};
}

View File

@ -51,5 +51,6 @@ public:
private:
ScreenUtils() = default;
~ScreenUtils() = default;
};

View File

@ -21,23 +21,28 @@
*/
#ifndef _TINY_SHA1_HPP_
#define _TINY_SHA1_HPP_
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stdint.h>
namespace sha1
{
class SHA1
{
namespace sha1 {
class SHA1 {
public:
typedef uint32_t digest32_t[5];
typedef uint8_t digest8_t[20];
inline static uint32_t LeftRotate(uint32_t value, size_t count) {
return (value << count) ^ (value >> (32 - count));
}
SHA1() { reset(); }
virtual ~SHA1() {}
SHA1(const SHA1 &s) { *this = s; }
const SHA1 &operator=(const SHA1 &s) {
memcpy(m_digest, s.m_digest, 5 * sizeof(uint32_t));
memcpy(m_block, s.m_block, 64);
@ -45,6 +50,7 @@ namespace sha1
m_byteCount = s.m_byteCount;
return *this;
}
SHA1 &reset() {
m_digest[0] = 0x67452301;
m_digest[1] = 0xEFCDAB89;
@ -55,6 +61,7 @@ namespace sha1
m_byteCount = 0;
return *this;
}
SHA1 &processByte(uint8_t octet) {
this->m_block[this->m_blockByteIndex++] = octet;
++this->m_byteCount;
@ -64,6 +71,7 @@ namespace sha1
}
return *this;
}
SHA1 &processBlock(const void *const start, const void *const end) {
const uint8_t *begin = static_cast<const uint8_t *>(start);
const uint8_t *finish = static_cast<const uint8_t *>(end);
@ -73,11 +81,13 @@ namespace sha1
}
return *this;
}
SHA1 &processBytes(const void *const data, size_t len) {
const uint8_t *block = static_cast<const uint8_t *>(data);
processBlock(block, block + len);
return *this;
}
const uint32_t *getDigest(digest32_t digest) {
size_t bitCount = this->m_byteCount * 8;
processByte(0x80);
@ -105,6 +115,7 @@ namespace sha1
memcpy(digest, m_digest, 5 * sizeof(uint32_t));
return digest;
}
const uint8_t *getDigestBytes(digest8_t digest) {
digest32_t d32;
getDigest(d32);
@ -186,6 +197,7 @@ namespace sha1
m_digest[3] += d;
m_digest[4] += e;
}
private:
digest32_t m_digest;
uint8_t m_block[64];