1 Star 0 Fork 0

bubuzi_tool/cryptopp870

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
dsa.cpp 1.19 KB
Copy Edit Raw Blame History
布布子 authored 2022-12-12 16:37 . 初始化提交
// dsa.cpp - originally written and placed in the public domain by Wei Dai
#include "pch.h"
#ifndef CRYPTOPP_IMPORTS
#include "dsa.h"
#include "asn.h"
#include "integer.h"
#include "filters.h"
#include "nbtheory.h"
NAMESPACE_BEGIN(CryptoPP)
size_t DSAConvertSignatureFormat(byte *buffer, size_t bufferSize, DSASignatureFormat toFormat, const byte *signature, size_t signatureLen, DSASignatureFormat fromFormat)
{
Integer r, s;
StringStore store(signature, signatureLen);
ArraySink sink(buffer, bufferSize);
switch (fromFormat)
{
case DSA_P1363:
r.Decode(store, signatureLen/2);
s.Decode(store, signatureLen/2);
break;
case DSA_DER:
{
BERSequenceDecoder seq(store);
r.BERDecode(seq);
s.BERDecode(seq);
seq.MessageEnd();
break;
}
case DSA_OPENPGP:
r.OpenPGPDecode(store);
s.OpenPGPDecode(store);
break;
}
switch (toFormat)
{
case DSA_P1363:
r.Encode(sink, bufferSize/2);
s.Encode(sink, bufferSize/2);
break;
case DSA_DER:
{
DERSequenceEncoder seq(sink);
r.DEREncode(seq);
s.DEREncode(seq);
seq.MessageEnd();
break;
}
case DSA_OPENPGP:
r.OpenPGPEncode(sink);
s.OpenPGPEncode(sink);
break;
}
return (size_t)sink.TotalPutLength();
}
NAMESPACE_END
#endif
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/bubuzi_tool/cryptopp870.git
git@gitee.com:bubuzi_tool/cryptopp870.git
bubuzi_tool
cryptopp870
cryptopp870
master

Search

0d507c66 1850385 C8b1a773 1850385