@@ -62,3 +62,58 @@ pub trait DigestVerifier<D: Update, S> {
6262 signature : & S ,
6363 ) -> Result < ( ) , Error > ;
6464}
65+
66+ /// Asynchronously verify the provided message bytestring using `Self`.
67+ ///
68+ /// This trait is an async equivalent of the [`Verifier`] trait.
69+ pub trait AsyncVerifier < S > {
70+ /// Asynchronously verify that the provided signature for a given message
71+ /// bytestring is authentic.
72+ ///
73+ /// Returns `Error` if it is inauthentic, or otherwise returns `()`.
74+ async fn verify_async ( & self , msg : & [ u8 ] , signature : & S ) -> Result < ( ) , Error > ;
75+ }
76+
77+ impl < S , T > AsyncVerifier < S > for T
78+ where
79+ T : Verifier < S > ,
80+ {
81+ async fn verify_async ( & self , msg : & [ u8 ] , signature : & S ) -> Result < ( ) , Error > {
82+ self . verify ( msg, signature)
83+ }
84+ }
85+
86+ /// Asynchronous equivalent of [`MultipartVerifier`] where the message is
87+ /// provided in non-contiguous byte slices.
88+ ///
89+ /// This trait is an async equivalent of the [`MultipartVerifier`] trait.
90+ pub trait AsyncMultipartVerifier < S > {
91+ /// Async equivalent of [`MultipartVerifier::multipart_verify()`] where the
92+ /// message is provided in non-contiguous byte slices.
93+ async fn multipart_verify_async ( & self , msg : & [ & [ u8 ] ] , signature : & S ) -> Result < ( ) , Error > ;
94+ }
95+
96+ impl < S , T > AsyncMultipartVerifier < S > for T
97+ where
98+ T : MultipartVerifier < S > ,
99+ {
100+ async fn multipart_verify_async ( & self , msg : & [ & [ u8 ] ] , signature : & S ) -> Result < ( ) , Error > {
101+ self . multipart_verify ( msg, signature)
102+ }
103+ }
104+
105+ /// Asynchronously verify the provided signature for the given prehashed
106+ /// message `Digest` is authentic.
107+ #[ cfg( feature = "digest" ) ]
108+ pub trait AsyncDigestVerifier < D : Update , S > {
109+ /// Asynchronously verify the signature against the received `Digest`
110+ /// output, by updating it with the message.
111+ ///
112+ /// The given function can be invoked multiple times. It is expected that
113+ /// in each invocation the `Digest` is updated with the entire equal message.
114+ async fn verify_digest_async < F : AsyncFn ( & mut D ) -> Result < ( ) , Error > > (
115+ & self ,
116+ f : F ,
117+ signature : & S ,
118+ ) -> Result < ( ) , Error > ;
119+ }
0 commit comments