Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70862cb9e4 |
No files matched your search
@@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## 0.5.1 - 2026-10-05
|
||||
|
||||
### Changed
|
||||
|
||||
- Require BearSSL 0.3.0 or newer and use its managed PEM decoder interface.
|
||||
|
||||
## 0.5.0 - 2026-09-29
|
||||
|
||||
### Added
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
# Package
|
||||
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
author = "Jonathan Bernard"
|
||||
description = "Full JWT, JWS, JWE, and JWK implementation for Nim, compliant with RFCs 7515-7519."
|
||||
license = "GPL-3.0-or-later"
|
||||
@@ -9,7 +9,7 @@ srcDir = "src/main"
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 1.4.8"
|
||||
requires "bearssl"
|
||||
requires "bearssl >= 0.3.0"
|
||||
requires "https://github.com/yglukhov/bearssl_pkey_decoder"
|
||||
|
||||
task unittest, "Run the unit test suites.":
|
||||
|
||||
@@ -13,30 +13,28 @@ proc decodePem*(
|
||||
) =
|
||||
|
||||
var pemCtx: PemDecoderContext
|
||||
pemDecoderInit(pemCtx)
|
||||
pemCtx.init()
|
||||
|
||||
var offset: uint = 0
|
||||
var bytesRemaining: uint = uint len(pem)
|
||||
var offset = 0
|
||||
var readingObj = false
|
||||
|
||||
while bytesRemaining > 0:
|
||||
let bytesRead = pemDecoderPush(pemCtx, unsafeAddr pem[offset], uint bytesRemaining)
|
||||
while offset < pem.len:
|
||||
let bytesRead = pemCtx.push(pem.toOpenArray(offset, pem.high))
|
||||
offset += bytesRead
|
||||
bytesRemaining -= bytesRead
|
||||
|
||||
case pemDecoderEvent(pemCtx):
|
||||
case pemCtx.lastEvent():
|
||||
of PEM_BEGIN_OBJ:
|
||||
if readingObj:
|
||||
raise newException(ValueError,
|
||||
"Invalid PEM: saw a second BEGIN before seeing END.")
|
||||
|
||||
if pemDecoderName(pemCtx) != expectedObjectName:
|
||||
if pemCtx.banner() != expectedObjectName:
|
||||
raise newException(ValueError,
|
||||
"Invalid PEM: expected BEGIN " & expectedObjectName &
|
||||
" but got BEGIN " & $pemDecoderName(pemCtx))
|
||||
" but got BEGIN " & pemCtx.banner())
|
||||
|
||||
readingObj = true
|
||||
pemDecoderSetdest(pemCtx, callback, keyCtx)
|
||||
pemCtx.setdest(callback, keyCtx)
|
||||
|
||||
of PEM_END_OBJ:
|
||||
if readingObj: readingObj = false
|
||||
|
||||
Reference in new issue
Block a user