[#77] protogen: Initial implementation

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-04-25 15:13:10 +03:00
parent a28ceb251a
commit adb7c602d7
115 changed files with 36376 additions and 20397 deletions

View file

@ -63,12 +63,6 @@ func SignDataWithHandler(key *ecdsa.PrivateKey, src DataSource, handler KeySigna
}
func VerifyDataWithSource(dataSrc DataSource, sigSrc KeySignatureSource, opts ...SignOption) error {
cfg := defaultCfg()
for i := range opts {
opts[i](cfg)
}
buffer := buffersPool.Get(uint32(dataSrc.SignedDataSize()))
defer buffersPool.Put(buffer)
@ -77,7 +71,7 @@ func VerifyDataWithSource(dataSrc DataSource, sigSrc KeySignatureSource, opts ..
return err
}
return verify(cfg, data, sigSrc())
return VerifyDataSlice(data, sigSrc, opts...)
}
func SignData(key *ecdsa.PrivateKey, v DataWithSignature, opts ...SignOption) error {
@ -87,3 +81,13 @@ func SignData(key *ecdsa.PrivateKey, v DataWithSignature, opts ...SignOption) er
func VerifyData(src DataWithSignature, opts ...SignOption) error {
return VerifyDataWithSource(src, src.GetSignature, opts...)
}
func VerifyDataSlice(data []byte, sigSrc KeySignatureSource, opts ...SignOption) error {
cfg := defaultCfg()
for i := range opts {
opts[i](cfg)
}
return verify(cfg, data, sigSrc())
}