File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,37 @@ static int tool_sign(int argc, const char *argv[])
132132 return EXIT_SUCCESS ;
133133}
134134
135+ static int tool_verify (int argc , const char * argv [])
136+ {
137+ libecdsaauth_key_t * key ;
138+ char inbuf [1024 ];
139+ size_t inlen ;
140+ bool verify ;
141+
142+ if (argc < 4 )
143+ {
144+ fprintf (stderr , "usage: ecdsatool verify privatekey.pem base64challenge base64signature\n" );
145+ return EXIT_FAILURE ;
146+ }
147+
148+ key = libecdsaauth_key_load (argv [1 ]);
149+ if (key == NULL )
150+ {
151+ fprintf (stderr , "loading key failed\n" );
152+ return EXIT_FAILURE ;
153+ }
154+
155+ inlen = base64_decode (argv [2 ], inbuf , sizeof inbuf );
156+
157+ verify = libecdsaauth_verify_base64 (key , inbuf , inlen , argv [3 ]);
158+
159+ libecdsaauth_key_free (key );
160+
161+ printf ("verified: %s\n" , verify ? "true" : "false" );
162+
163+ return EXIT_SUCCESS ;
164+ }
165+
135166static tool_applet_t tool_applets [];
136167
137168static int tool_usage (int argc , const char * argv [])
@@ -156,6 +187,7 @@ static tool_applet_t tool_applets[] = {
156187 {"pubkey" , tool_pubkey },
157188 {"keyinfo" , tool_keyinfo },
158189 {"sign" , tool_sign },
190+ {"verify" , tool_verify },
159191 {"usage" , tool_usage },
160192 {NULL , NULL }
161193};
You can’t perform that action at this time.
0 commit comments