added hmac validation (#1)
All checks were successful
🧪 ✨ Unit Tests Workflow / 🔍 🐹 Go Tests (push) Successful in 1m5s

Reviewed-on: #1
Co-authored-by: Ron Rise <ron@siteworxpro.com>
Co-committed-by: Ron Rise <ron@siteworxpro.com>
This commit was merged in pull request #1.
This commit is contained in:
2026-02-06 22:45:41 +00:00
committed by Siteworx Pro Gitea
parent 9f58437d0e
commit 6a9269fa9c
3 changed files with 68 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ import (
"crypto/sha512"
"crypto/x509"
"encoding/pem"
"fmt"
"os"
)
@@ -85,6 +86,10 @@ func (f *EncryptedFile) GenerateSymmetricKey() error {
func (f *EncryptedFile) ParsePublicPem() error {
pemKeyBin, _ := pem.Decode(f.PublicPem)
if pemKeyBin == nil {
return fmt.Errorf("failed to parse PEM block containing the public key")
}
if bytes.Contains(f.PublicPem, []byte("-----BEGIN PUBLIC KEY-----")) {
key, err := x509.ParsePKIXPublicKey(pemKeyBin.Bytes)
if err != nil {
@@ -109,6 +114,10 @@ func (f *EncryptedFile) ParsePublicPem() error {
func (f *EncryptedFile) ParsePrivatePem() error {
pemKeyBin, _ := pem.Decode(f.privatePem)
if pemKeyBin == nil {
return fmt.Errorf("failed to parse PEM block containing the private key")
}
if bytes.Contains(f.privatePem, []byte("-----BEGIN PRIVATE KEY-----")) {
key, err := x509.ParsePKCS8PrivateKey(pemKeyBin.Bytes)
if err != nil {