Software /
code /
prosody
Comparison
util/paseto.lua @ 12710:2dbb3335cd34
util.paseto: Error early on invalid keys
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 11 Jul 2022 14:08:55 +0100 |
parent | 12709:b3f7c77c1f08 |
child | 12711:9e9f158d6699 |
comparison
equal
deleted
inserted
replaced
12709:b3f7c77c1f08 | 12710:2dbb3335cd34 |
---|---|
104 }; | 104 }; |
105 end | 105 end |
106 | 106 |
107 function v4_public.import_public_key(pem) | 107 function v4_public.import_public_key(pem) |
108 local key = crypto.import_public_pem(pem); | 108 local key = crypto.import_public_pem(pem); |
109 assert(key:get_type() == "ED25519", "Invalid public key type for v4.public"); | |
109 return setmetatable({ | 110 return setmetatable({ |
110 key = key; | 111 key = key; |
111 }, v4_public_pubkey_mt); | 112 }, v4_public_pubkey_mt); |
112 end | 113 end |
113 | 114 |
114 function v4_public.import_private_key(pem) | 115 function v4_public.import_private_key(pem) |
115 local key = crypto.import_private_pem(pem); | 116 local key = crypto.import_private_pem(pem); |
117 assert(key:get_type() == "ED25519", "Invalid private key type for v4.public"); | |
116 return setmetatable({ | 118 return setmetatable({ |
117 key = key; | 119 key = key; |
118 }, v4_public_privkey_mt); | 120 }, v4_public_privkey_mt); |
119 end | 121 end |
120 | 122 |