Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix pdf_signature_dictionary naming #1814

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ class PdfSignatureDictionary implements IPdfWrapper {

/// internal method
List<int>? getPkcs7Content() {
String? hasalgorithm = '';
String? hashAlgorithm = '';
_SignaturePrivateKey externalSignature;
List<List<int>>? crlBytes;
List<int>? ocspByte;
Expand All @@ -403,7 +403,7 @@ class PdfSignatureDictionary implements IPdfWrapper {
chain = PdfSignatureHelper.getHelper(_sig!).externalChain;
final String digest = getDigestAlgorithm(externalSigner.hashAlgorithm);
final _SignaturePrivateKey pks = _SignaturePrivateKey(digest);
hasalgorithm = pks.getHashAlgorithm();
hashAlgorithm = pks.getHashAlgorithm();
externalSignature = pks;
} else {
String certificateAlias = '';
Expand Down Expand Up @@ -438,19 +438,19 @@ class PdfSignatureDictionary implements IPdfWrapper {
? getDigestAlgorithm(_sig!.digestAlgorithm)
: MessageDigestAlgorithms.secureHash256;
final _SignaturePrivateKey pks = _SignaturePrivateKey(digest, parameters);
hasalgorithm = pks.getHashAlgorithm();
hashAlgorithm = pks.getHashAlgorithm();
externalSignature = pks;
}
final _PdfCmsSigner pkcs7 =
_PdfCmsSigner(null, chain!, hasalgorithm!, false);
_PdfCmsSigner(null, chain!, hashAlgorithm!, false);
final IRandom source = getUnderlyingSource();
final List<IRandom?> sources =
List<IRandom?>.generate(_range.length ~/ 2, (int i) => null);
for (int j = 0; j < _range.length; j += 2) {
sources[j ~/ 2] = _WindowRandom(source, _range[j], _range[j + 1]);
}
final PdfStreamReader data = _RandomStream(_RandomGroup(sources));
final List<int> hash = pkcs7._digestAlgorithm.digest(data, hasalgorithm)!;
final List<int> hash = pkcs7._digestAlgorithm.digest(data, hashAlgorithm)!;
final List<int>? sh = pkcs7
.getSequenceDataSet(
hash, ocspByte, crlBytes, _sig!.cryptographicStandard)
Expand All @@ -473,13 +473,13 @@ class PdfSignatureDictionary implements IPdfWrapper {
pkcs7.setSignedData(
extSignature!, null, externalSignature.getEncryptionAlgorithm());
return pkcs7.sign(hash, null, null, ocspByte, crlBytes,
_sig!.cryptographicStandard, hasalgorithm);
_sig!.cryptographicStandard, hashAlgorithm);
}

/// internal method
Future<List<int>?> getPkcs7ContentAsync() async {
List<int>? pkcs7Content;
String? hasalgorithm = '';
String? hashAlgorithm = '';
_SignaturePrivateKey? externalSignature;
List<List<int>>? crlBytes;
List<int>? ocspByte;
Expand All @@ -491,7 +491,7 @@ class PdfSignatureDictionary implements IPdfWrapper {
chain = PdfSignatureHelper.getHelper(_sig!).externalChain;
final String digest = getDigestAlgorithm(externalSigner.hashAlgorithm);
final _SignaturePrivateKey pks = _SignaturePrivateKey(digest);
hasalgorithm = pks.getHashAlgorithm();
hashAlgorithm = pks.getHashAlgorithm();
externalSignature = pks;
} else {
String certificateAlias = '';
Expand Down Expand Up @@ -527,13 +527,13 @@ class PdfSignatureDictionary implements IPdfWrapper {
: MessageDigestAlgorithms.secureHash256;
final _SignaturePrivateKey pks =
_SignaturePrivateKey(digest, parameters);
hasalgorithm = pks.getHashAlgorithm();
hashAlgorithm = pks.getHashAlgorithm();
externalSignature = pks;
});
});
}
final _PdfCmsSigner pkcs7 =
_PdfCmsSigner(null, chain!, hasalgorithm!, false);
_PdfCmsSigner(null, chain!, hashAlgorithm!, false);
final IRandom source = getUnderlyingSource();
final List<IRandom?> sources =
List<IRandom?>.generate(_range.length ~/ 2, (int i) => null);
Expand All @@ -542,7 +542,7 @@ class PdfSignatureDictionary implements IPdfWrapper {
}
final PdfStreamReader data = _RandomStream(_RandomGroup(sources));
await pkcs7._digestAlgorithm
.digestAsync(data, hasalgorithm)
.digestAsync(data, hashAlgorithm)
.then((List<int>? hash) async {
await pkcs7
.getSequenceDataSetAsync(
Expand Down Expand Up @@ -575,7 +575,7 @@ class PdfSignatureDictionary implements IPdfWrapper {
await pkcs7.setSignedDataAsync(extSignature!, null,
externalSignature!.getEncryptionAlgorithm());
pkcs7Content = await pkcs7.signAsync(hash, null, null, ocspByte,
crlBytes, _sig!.cryptographicStandard, hasalgorithm);
crlBytes, _sig!.cryptographicStandard, hashAlgorithm);
}
});
});
Expand Down