Commit Graph

23 Commits

Author SHA1 Message Date
Ramtin Nouri
971b897d7b 🔑 Support Ed25519 for LibreSSL 3.7.1+ (#407)
* Support Ed25519 for LibreSSL 3.7.1+

* fix EdDSACertificate error code test for new implementation

---------

Co-authored-by: Chris McArthur <prince.chrismc@gmail.com>
2026-02-16 21:02:20 -08:00
Chris Mc
179beb3627 ⬆️ Update LibreSSL version up to 4.2.1 (#410)
* Update LibreSSL version to 4.2.1 in CI configuration and documentation

* update OpenSSLErrorTest for LibreSSL 4.2.0+

Add Linux LibreSSL support in CMake presets

* add debug output to failure for all ssl libraries

* fix type in libressl version check

* chore: lint
2026-02-16 20:03:33 -08:00
Chris Mc
0ab9469c7d Update workflows for new GitHub Action Runner Images (#382)
* use ubuntu-latest + update actions/cache

* performance-avoid-endl

https://clang.llvm.org/extra/clang-tidy/checks/performance/avoid-endl.html

* misc-const-correctness

https://clang.llvm.org/extra/clang-tidy/checks/misc/const-correctness.html

* misc-const-correctness

https://clang.llvm.org/extra/clang-tidy/checks/misc/const-correctness.html

* formatting

* clang format and tidy and already installed

https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md#language-and-runtime

* explict clang-format-14

* disable include cleaner

* format

* format

* install lcov to get patching geninfo for gcc 13

* revert "install lcov to get patching geninfo for gcc 13"
2025-05-13 17:35:46 -04:00
Tom Hughes
c870903d9f Add helper for making EC key from components (#358) 2024-08-08 21:44:30 -07:00
Juliusz Sosinowicz
a968dfe4f7 Fix build and tests for wolfSSL (#352)
* Fix build and tests for wolfSSL

Signed-off-by: Juliusz Sosinowicz <juliusz@wolfssl.com>

* Remove unnecessary symbols

* Don't fail fast on wolfSSL actions

* Include wolfssl/options.h explicitly

* Fix old wolfSSL failures

* remove unused EVP_PKEY_get1_RSA

this is deprecated with 3.0

* code review comments

* Apply suggestions from code review

* rm extra headers?

* fix cmake test

use the new macro that was required

* linter

* fix unused warning fail_HMAC

* reenable fail fast

* fix spelling

---------

Signed-off-by: Juliusz Sosinowicz <juliusz@wolfssl.com>
Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
2024-07-29 08:14:34 -07:00
Chris Mc
953aab6fe4 Add helper for making RSA key from exponent and modulus (#307)
* - Added creation of public key from its components
- Split verify function to signature and claims
- Added handling of claims set in json while creating a verifier

* - Added creation of public key from its components
- Split verify function to signature and claims
- Added handling of claims set in json while creating a verifier

* Fixed missing lines

* Added unit tests

* Additional changes

* delete

* refactor free

* remove testing

* align white space

* Update tests/PubKeyTest.cpp

Yes I should have removed it. Used it in testing

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* Add support for 1.0.2

* refactor a bit

* user jwt define for SSL API that is cross-library

* add support for no base64 from jwt

* refactor a bit more

* fixup wolfssl + linters

* missing include for openssl 3

* quick draft of openssl 3 implementation

* linter

* add in a health layer of error handling and memory management

* flip function order

* fix typo

* error tests for openssl

* more all helper tests to one file

* update cmake

* update tests

* more negative test cases

* fixup old api calls depending on version

* linter

* fixup return types

* disable failing tests

* fixup copy passed

* disable more tests

* fixup broke tests

* better error code handling

* test asan with more openssl versions

* fix template render path

* fix cache conflict

running different ubuntu docker images for with different GLIB c and cxx ABIs

* add missing lib to tests

* run both openssl versions with asan

* openssl code always calls new and returns an adress in most cases

so always save the pointer to call free?

* go back to old raw2bn implementation

* Revert "openssl code always calls new and returns an adress in most cases"

This reverts commit 45e85b8c667587236ac3dd255d1450bcf22f5723.

* remove add new tests (needs to be a seperate pr)

* fix jwks verify example + run with asan+lsan

* some extra backwards compat for ssl1.1

* compat rsa keygen

* fixup copy paste

* fix typo

* linter

* wolfssl compat

* compat 1.1.0i

* more compat

since they changed the API with ever version

* linter

* fix 1.1.0

* more compat

* more compat

working on the matrix of wolfssl and libress and 1.1.0

* updated example with hardcoded values

* action to install openssl now sets ENV vars for CMake

https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/FindOpenSSL.cmake#L233

https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable

https://gitlab.kitware.com/cmake/cmake/-/issues/24236

* update example to create a valid token

* update asan to latest compiler

* clang tidy

* fix memory leak in openssl 1.1.1

this is theoretically only because of the test code but better safe then sorry

* clang format

* improve docs

* enable one more test

* fix test impl signature

* more test for bio to std::string

* DRY up code with new helper for write_bio_to_string

* fix copy paste + spell checking

* linter

* fix typo

* fix return type

* BIO_get_mem_data is just a define

so fixup error implementation to match

* put extra tests in too many places

its only for certs not just pubkeys

---------

Co-authored-by: ZOHARGO <zohargo@amdocs.com>
Co-authored-by: zgofer1 <zgofer@gmail.com>
2023-12-26 12:23:21 -05:00
Chris Mc
8cb307a8eb Remove duplicated key handlers (#318)
* add a quick test to see if rsa helpers handle ec certs

LoadPublicKeyFromStringReferenceWithEcCert

* run all tests with generic helper

* template out error category and new tests

* linter

* missing enum entry

* does convert_base64_der_to_pem work with ecdsa?

* use correct EC curve functions

* missing extern symbol

* dont change behavior

* typo

* fix tests

* update private key to be more generic

* fixup 2 more tests

* update exception for libressl 3.5.3

https://github.com/Thalhammer/jwt-cpp/actions/runs/7161143039/job/19496334109?pr=318#step:8:248

```
[ RUN      ] OpenSSLErrorTest.ECDSACertificate
/home/runner/work/jwt-cpp/jwt-cpp/tests/OpenSSLErrorTest.cpp:487: Failure
Expected equality of these values:
  ec
    Which is: ecdsa_error:19
  e.expected_ec
    Which is: rsa_error:12
```

* linter

* add missing test

* fix copy paste

* typo part 2
2023-12-12 09:49:26 -05:00
Chris Mc
5032d59124 🧹 Removing extra exception aliases (#257)
* remove exception outside of error namespace

* linter
2022-10-05 09:09:02 +02:00
Dominik Thalhammer
3ed4ff9704 Use EVP_PKEY_up_ref if available (#238) 2022-09-13 08:52:13 +02:00
Chris Mc
c9a511f436 🔒 Update SSL libraries to latest versions (#235)
* Bump test SSL libraries

* Fix copy paste error

* fix bad spacing

* Update README.md

* bump again

* remove libressl 3.5.3

* Update ssl.yml

* put back 3.5.x for failing badge

* Update action.yml

* point URLs back to main since testing worked

* Only publish badge on push

leftover from me testing on my fork 25 days ago 😭

* Trying using 1.1 apis with libressl

https://github.com/libressl-portable/portable/issues/764#issuecomment-1153548504

Co-Authored-By: Theo Buehler <botovq@users.noreply.github.com>

* Limit new APIs to required version

limit change to older supported versions

* Update tests for new libressl APIs

Co-authored-by: Theo Buehler <botovq@users.noreply.github.com>
2022-06-14 09:02:34 -07:00
Jan Blome
d7e0936d84 🔧 Fix build with OPENSSL_NO_DEPRECATED (#228)
* Add missing include to fix build with OPENSSL_NO_DEPRECATED

Creating and verifying RSA signatures requires some OpenSSL functions
declared in the `openssl/rsa.h` header. When `OPENSSL_NO_DEPRECATED` is
not defined this header gets indirectly included. But with this define
set the function declarations are missing. This commit adds an explicit
include for the file to fix this.

* Remove unused functions in OpenSSLErrorTest

Some functions from OpenSSL redefined in `OpenSSLErrorTest.cpp` use
types that are not available when `OPENSSL_NO_DEPRECATED` is defined.
Since they do not seem to be actually used this commit simply removes
them.

* Test with OPENSSL_NO_DEPRECATED

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
2022-05-12 16:43:47 -07:00
Marek Klein
275c750fa1 🔧 Replace deprecated OpenSSL functions (#191)
* do not use deprecated functions in ecdsa context

* check ecdsa key on creation

* add test

* set compiler flags correctly

* set compiler flags correctly attempt 2

Co-authored-by: Chris McArthur <prince.chrismc@gmail.com>
2021-12-12 10:25:43 -08:00
Marek Klein
55aaf31ad8 🔧 Replace RSA related deprecated functions (#189)
* RSA_size() --> EVP_PKEY_size()

* getting rid of deprecated functions in rsa-pss signature creation

* getting rid of deprecated functions in rsa-pss signature verification

* generate_hash not used in pss
2021-11-22 20:18:50 -08:00
Marek Klein
66eea980b5 🗜️ Simplify reading of EC keys (#185)
* simplify reading of EC keys

* fix formatting
2021-11-18 20:26:03 -08:00
Dominik Thalhammer
ac0424b115 Integrate Hunter package manager support (#163)
* Add initial hunter support
2021-09-04 21:24:23 +02:00
Aydin
402179d8fb 🔑 Using RSA_padding_add_PKCS1_PSS and RSA_verify_PKCS1_PSS functions (#159)
When both Hash and mgs1Hash parameters match in the _mgf1 equivalent calls,
or mgf1Hash is NULL, we can opt to use the non _mgf1 calls mentioned.
This change will allow wolfssl to be compiled with jwt-cpp.

Co-authored-by: Aydin Arik <aarik@teradici.com>
2021-09-01 12:01:37 -04:00
Chris Mc
23fd608caf 📈 Improving OpenSSL test coverage (#155)
This cleans up some of the testing for specific ssl versions, updates LibreSSL tests to the latest patch versions and adds badges for OpenSSL test.
2021-08-17 13:42:24 +02:00
Marek Klein
17fdd26d97 Fix tests for OpenSSL 3.0.0 (#153)
* update signatures of PEM_write_bio_PUBKEY and PEM_write_bio_X509
* run tests with openssl
* Update .github/workflows/openssl.yml
* fetch openssl from github

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
2021-08-13 13:33:43 +02:00
Chris Mc
b21d80c22e 🧰 Linting and maintenance (#120)
* some manual fixes to obtain

* fairly close enough

* whitespace fixes

* add comment

* adding clang format + applied

* add editorconfig (supported natively by github web editor)

* apply linting to project

* clean up CI workflows

* zap vcpkg folder

actual one is here
https://github.com/microsoft/vcpkg/tree/master/ports/jwt-cpp

* adding a logo

* thin the lines in the pluses

* use logo + more links to spec and examples

* Create lint.yml

* apply linting
2021-01-11 17:37:14 -05:00
Chris Mc
159527930e Make LibreSSL support official (tested against 3.3.0 along with CMake install) (#113)
outline to add libressl testing

add missing arg

fix bad copy paste

adding cmake option for openssl versus libressl

explicit directory

set cmake dirs

used seperate build folder + make directly

trying autotools

download cmake module

typo

link against correct ssl target

force openssl 1.0 API when using libressl

add missing macro

make sure to configure ssl error tests based on ssl lib/version

fix compare on min ssl version

fix compare

adding CMake install support to SSL optional

Make sure to copy fin package module

fix fake install path

Update cmake.yml

Update cmake.yml

Update tests/cmake/libressl-is-used.cpp

jwt header now configures itself for libressl (no externly dep on cmake)

this is acompnaied by a docker image to test libressl with

writing sheild.io json to seperate branch

fix bad syntax

make missing dirs

make sure to not overwrite files

add tables to advertise support

only update on push to master
2020-12-13 20:43:24 +01:00
Jaideep Bajwa
aa258bdfdf Add helper function to convert cert from base64DER to PEM (#106)
* Add helper function to convert cert from base64DER to PEM

This is particularly useful when dealing with JWKs x5c claim which
is encoded as base64 DER. With this helper function the client can
convert x5c claim to PEM, which makes it easy to interact with this
library.
2020-11-08 22:04:51 +01:00
Speeder
49d29e3d43 Added EdDSA support (#95)
* Fixed a build error

`jwt.h` previously depended on the nlohmann JSON library's inclusion of `iso646.h`, which defines the `not` operator.

* Added EdDSA support

https://github.com/Thalhammer/jwt-cpp/issues/79
Disabled EdDSA support when building with OpenSSL <1.1.1. Support for EdDSA came with OpenSSL version 1.1.1, incl. API extensions.

* Fixed build generation for Microsoft Visual Studio

* Fixed MSVC build warnings "hides previous local declaration"

* Fixed narrowing warnings when building with OpenSSL 1.0.2

* Compacted the string buffer initialization code pattern

As per review comment: https://github.com/Thalhammer/jwt-cpp/pull/95#discussion_r462985506

* adding eddsa openssl tests

* adding on mock openssl call as a test

* adding more mock openssl call to test failures

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
2020-08-03 23:40:08 +02:00
Dominik Thalhammer
9711259ef2 Openssl testing (#90)
* Add error_code support to algorithm::verify

* Add error_code support for signing

* Add error_code overloads to verifying

* Fix missing throw

* Improvements

* Remove unused throwing overloads

* Fix test on older gtest

* Found bug and added more testing

* Move exceptions into error namespace

* Initial implementation of openssl tests

* Fix tests for older compilers

* Only enable openssl test on openssl >=1.1
2020-07-21 18:47:10 +02:00