PublicKey は priv などどこかにある前提
署名は base64 でエンコードされて送られてくる前提
データは JSON を jsonx:decode(RawSignedData, [{format, proplist}]) でデコードされている前提
- include_lib ( "public_key/include/public_key.hrl" ).
- spec public_key ( binary ()) -> #'RSAPublicKey' {}.
public_key ( Filename ) ->
{ ok , RawPublicKey } = file : read_file ( Filename ),
[ PemEntryPublicKey ] = public_key : pem_decode ( RawPublicKey ),
public_key : pem_entry_decode ( PemEntryPublicKey ).
- spec verify ( binary (), binary (), #'RSAPublicKey' {}) -> boolan ().
verify ( SignedData , Signature , PublicKey ) when is_binary ( SignedData ) ->
RawSignature = base64 : decode ( Signature ),
RawSignedData = jsonx : encode ( SignedData ),
public_key : verify ( RawSignedData , sha , RawSignature , PublicKey ).
Enter fullscreen mode
Exit fullscreen mode
Top comments (0)