Commit Graph

52 Commits

Author SHA1 Message Date
mitaclaw 7ce170f138 Modernize `std::copy` with ranges 2024-10-10 00:53:48 -07:00
Dentomologist d627b78c46 Adjust order and spacing of various #includes
Move some #includes around to match the Contributing guidelines.
2024-07-26 14:28:34 -07:00
Admiral H. Curtiss 3a63633be3
Common/Crypto/SHA1: Use span and string_view for Context::Update() 2024-07-04 22:37:07 +02:00
LillyJadeKatrin 360f899f68
Common/Crypto/SHA1: Add DigestToString() utility function 2024-07-04 22:12:20 +02:00
Lioncash dbc792a3ec Common/Crypto/SHA1: Resolve -Wignored-attributes warnings
See commit 417d1310d22b11d5d724625721b5fec09eda099a for an explanation
on why we do this.
2023-12-13 13:04:53 -05:00
Lioncash bced5fac18 Common/Crypto/AES: Resolve -Wignored-attributes warnings
The alias for __m128i is typically something like:

typedef long long __m128i __attribute__((__vector_size__(16), __may_alias__));

and the part that ends up not getting preserved is the __may_alias__
attribute specifier.

So, in order to preserve that, we can just use a wrapper struct, so the
data type itself isn't being passed through the template.
2023-12-13 13:02:51 -05:00
Sketch 2154941c2c IOS/KD: Implement NWC24_CHECK_MAIL_NOW 2023-09-03 13:05:58 -04:00
Minty-Meeo 2bb619a508 Resolve [-Wstringop-overflow=] 2023-04-10 14:21:15 -05:00
JosJuice 454537d53e Replace BitUtils with C++20: RotateLeft/RotateRight
Now that we've flipped the C++20 switch, let's start making use of
the nice new <bit> header.

I'm planning on handling this move away from BitUtils.h incrementally
in a series of PRs. There may be a few functions remaining in
BitUtils.h by the end that C++20 doesn't have any equivalents for.
2022-12-11 08:59:18 +01:00
SketchMaster2001 e413d7f5ec
Add initial WiiConnect24 support 2022-10-16 04:19:36 +02:00
JosJuice 939fa1ed1c
Merge pull request #10941 from shuffle2/crypto-cleanup
Crypto cleanup
2022-08-05 12:12:34 +02:00
Shawn Hoffman bf5076eb01 crypto/sha1: add real workaround for msvc/arm64 bad codegen 2022-08-02 23:05:45 -07:00
Shawn Hoffman 78142e30cc crypto/sha1: simplify enablement of sha insns on non-msvc 2022-08-02 23:05:07 -07:00
Shawn Hoffman 4e6aa28da4 crypto/aes: silence warning on godforsaken android gcc 2022-08-02 23:03:51 -07:00
Shawn Hoffman d71797154a VolumeVerifier: enable fast hash functions by default
sets defaults based on cpu support.
2022-08-02 22:23:49 -07:00
Shawn Hoffman 46ad8b9d68 Implement hw accelerated AES 2022-08-01 10:00:42 -07:00
Shawn Hoffman 97ff757a74 SHA1/arm64: fix casting warning on certain gcc 2022-07-30 12:06:21 -07:00
Shawn Hoffman 8939210d8a Common/Crypto/SHA1: implement accelerated versions 2022-07-27 01:07:48 -07:00
Shawn Hoffman dd29a54cf6 introduce wrapper for SHA1 functionality 2022-07-26 22:16:37 -07:00
Pokechu22 2025763420 Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
Shawn Hoffman c89ae53677 msvc: remove warning disables which no longer fire 2021-07-17 18:24:36 -07:00
Pierre Bourdon 51cdc5542c
licensing: fix license info for Crypto/{bn,ec}
This code was part of Dolphin's relicensing from v2 to v2+ a while back,
we just never updated these copyright headers. I double-checked that
segher gave us permission to relicense this code to v2+ on 2015-05-16.
2021-07-05 04:35:56 +02:00
Pierre Bourdon e149ad4f0a
treewide: convert GPLv2+ license info to SPDX tags
SPDX standardizes how source code conveys its copyright and licensing
information. See https://spdx.github.io/spdx-spec/1-rationale/ . SPDX
tags are adopted in many large projects, including things like the Linux
kernel.
2021-07-05 04:35:56 +02:00
JosJuice 2137fb7813 Externals: Add zstd
I had to rename Source/Common/Compiler.h because the VS build
confuses it with Externals/zstd/lib/common/compiler.h otherwise.
2020-05-13 20:53:10 +02:00
Lioncash 8e030a4a45 Common: Use nested namespace specifiers where applicable 2019-06-17 16:36:48 -04:00
Léo Lam cb168f22d6 Replace custom UNUSED macro with [[maybe_unused]] 2019-05-04 23:04:18 +02:00
Lioncash d8f6d60189 Compiler: Rename UNUSED macro to DOLPHIN_UNUSED
UNUSED is quite a generic macro name and has potential to clash with
other libraries, so rename it to DOLPHIN_UNUSED to prevent that, as well
as make its naming consistent with the force inline macro
2018-06-09 12:20:29 -04:00
Lioncash 03414e8e84 Common: Add header for compiler-specifics
Instead of globbing things under an ambiguous Common.h header, move
compiler-specifics over to Compiler.h. This gives us a dedicated home
for anything related to compilers that we want to make functional across
all compilers that we support.

This moves us a little closer to eliminating Common.h entirely.
2018-06-09 12:10:05 -04:00
Léo Lam fff1db9730 Common: Add Random utilities
This makes it easier to generate random numbers or fill a buffer with
random data in a cryptographically secure way.

This also replaces existing usages of RNG functions in the codebase:

* <random> is pretty hard to use correctly, and std::random_device does
  not give enough guarantees about its results (it's
  implementation-defined, non cryptographically secure and could be
  deterministic on some platforms).
  Doing things correctly is error prone and verbose.

* rand() is terrible and should not be used especially in crypto code.
2018-05-31 17:54:43 +02:00
Léo Lam bea1e38c67 Move ECCSignature to Common::ec and give it a less confusing name 2018-05-27 14:01:38 +02:00
Léo Lam cec7fded60 IOSC: Implement VerifyPublicKeySign for ECC 2018-05-20 20:04:53 +02:00
Léo Lam 355b1b5d5b ec: Improve readability and clarity
- Move all of the ec functions into the Common::ec namespace.

- Give the public functions better names and some usage information.

- Move all of the "elt" related functions into an "elt" class including
  all of the arithmetic operations, so that the logic becomes clearer
  and feels less like assembly.

  This also makes it much more obvious what the parameters are, instead
  of only using unsigned char* (which doesn't tell anything about what
  the pointer is used for or the size).

- Similarly, add a new "Point" class and move point functions there.
  Overload the arithmetic operators to make calculations easier to read
2018-05-20 19:59:26 +02:00
Léo Lam e83591f188 ec: Avoid exposing internal function 2018-05-20 19:59:26 +02:00
Léo Lam b9dd94b9b2 bn: Use int instead of u32 for sizes
The loops relied on unsigned integer overflow, which is not immediately
obvious. Replace them with less clever variants that are clearer.

Also implement bn_compare using std::memcmp.
2018-05-20 19:59:26 +02:00
Shawn Hoffman 4f9dd7277b msvc: disable unused symbol warning in Core/Common/Crypto/ec.cpp 2017-06-07 18:44:03 -07:00
Léo Lam f8fb9e2d03 IOS: Implement IOSC-like API
This prevents the IOS crypto code and keys from being spread over
the codebase. Things only have to be implemented once, and can be
used everywhere from the IOS code.

Additionally, since ES exposes some IOSC calls directly (DeleteObject
and Encrypt/Decrypt), we need this for proper emulation.

Currently, this only supports AES key objects.
2017-05-02 23:49:22 +02:00
Léo Lam 9c31d6f5c5 IOS/ES: Handle personalised tickets properly
IOS unpersonalises device-specific ("personalised") tickets prior to
storing them on the NAND.
2017-03-11 21:14:26 +01:00
Léo Lam 5104caf6a6 Move AES code to Common/Crypto 2017-02-26 19:46:30 +01:00
Pierre Bourdon 3570c7f03a Reformat all the things. Have fun with merge conflicts. 2016-06-24 10:43:46 +02:00
mathieui 3e283ea9f1 More asterisks 2016-01-21 21:16:51 +01:00
Tillmann Karras 30ebb2459e Set copyright year to when a file was created 2015-05-25 13:22:31 +02:00
Tillmann Karras cefcb0ace9 Update license headers to GPLv2+ 2015-05-25 13:22:31 +02:00
Rohit Nirmal 46057db37d Fix build failing when disabling precompiled headers. 2014-09-19 18:17:51 -04:00
Rohit Nirmal fbc64984ca Include CommonTypes.h instead of Common.h. 2014-09-08 15:39:58 -04:00
Tillmann Karras 0ccee6c87b Fix warnings unearthed by #579 2014-07-13 02:16:51 +02:00
degasus 22e1aa5bb4 mark all local functions as static 2014-07-11 16:07:23 +02:00
Matthew Parlane 31cfc73a09 Fixes spacing for "for", "while", "switch" and "if"
Also moved && and || to ends of lines instead of start.
Fixed misc vertical alignments and some { needed newlining.
2014-03-11 00:35:07 +13:00
Tillmann Karras d802d39281 clang-modernize -use-nullptr
and s/\bNULL\b/nullptr/g for *.cpp/h/mm files not compiled on my machine
2014-03-09 21:14:26 +01:00
Tillmann Karras 46e7c0657f Crypto: small cleanup 2014-02-28 12:43:22 +01:00
Lioncash 2afe215271 Convert all includes to relative paths. 2014-02-18 02:19:10 -05:00