Changeset

12710:2dbb3335cd34

util.paseto: Error early on invalid keys
author Matthew Wild <mwild1@gmail.com>
date Mon, 11 Jul 2022 14:08:55 +0100
parents 12709:b3f7c77c1f08
children 12711:9e9f158d6699
files util/paseto.lua
diffstat 1 files changed, 2 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/util/paseto.lua	Mon Jul 11 13:51:39 2022 +0100
+++ b/util/paseto.lua	Mon Jul 11 14:08:55 2022 +0100
@@ -106,6 +106,7 @@
 
 function v4_public.import_public_key(pem)
 	local key = crypto.import_public_pem(pem);
+	assert(key:get_type() == "ED25519", "Invalid public key type for v4.public");
 	return setmetatable({
 		key = key;
 	}, v4_public_pubkey_mt);
@@ -113,6 +114,7 @@
 
 function v4_public.import_private_key(pem)
 	local key = crypto.import_private_pem(pem);
+	assert(key:get_type() == "ED25519", "Invalid private key type for v4.public");
 	return setmetatable({
 		key = key;
 	}, v4_public_privkey_mt);