27.10.2004 10:51:46Проверка подписи Ответов: 5
Александр
Здравствуйте.
По какому алгоритму функция CryptMsgUpdate() будет вычислять хэш, если сообщение открыто для декодирования без указания криптопровайдеда и в документе содержится две подписи на разных криптопровайдерах.
Спасибо.
 
Ответы:
27.10.2004 15:06:07kure
Теоретически.
Формат SigndedData PKCS#7 в заголовке содержит перечень алгоритмов хешей используемых для создания проверки подписей.
The signed-data content type shall have ASN.1 type SignedData:

SignedData ::= SEQUENCE {
version Version,
digestAlgorithms DigestAlgorithmIdentifiers,
contentInfo ContentInfo,
certificates
[0] IMPLICIT ExtendedCertificatesAndCertificates
OPTIONAL,
crls
[1] IMPLICIT CertificateRevocationLists OPTIONAL,
signerInfos SignerInfos }

DigestAlgorithmIdentifiers ::=

SET OF DigestAlgorithmIdentifier

SignerInfos ::= SET OF SignerInfo

Сами подписи в SignerInfo.
Если подписей несколько и они разные в заголовке будет пречень разных алгоритмо, а конкретный алгоритм хеша в соответствующей структуре SignerInfo.

SignerInfo ::= SEQUENCE {
version Version,
issuerAndSerialNumber IssuerAndSerialNumber,
digestAlgorithm DigestAlgorithmIdentifier,
authenticatedAttributes
[0] IMPLICIT Attributes OPTIONAL,
digestEncryptionAlgorithm
DigestEncryptionAlgorithmIdentifier,
encryptedDigest EncryptedDigest,
unauthenticatedAttributes
[1] IMPLICIT Attributes OPTIONAL }

27.10.2004 15:14:59Александр
Это я знаю.
тогда получается так:
если функия CryptMsgUpdate() видит что в заголовке несколько алгоритмов хэша и не указан криптопровайдер, то она параллельно считает хэш по указанным алгоритмам, а по окончании помешает посчитанные хэши в соответствующие структуры.
Я прав или нет?
Спасибо.
27.10.2004 15:31:59kure
По идее должно быть так.
По перечню хешей инициализируются нужное количество провайдеров, реализующих эти алгоритмы. По ним считается хеш. Потом проверяется подпись.
27.10.2004 15:54:02Александр
Т.е. Вы точно не уверены?
В принципе можно провести эксперимент:
-подписать файл два раза;
-потом проверить (должно быть в два раза дольше).
Спасибо!
27.10.2004 16:02:00kure
Теория описана в RFC (н-р, rfc2315)
The process by which signed data is constructed involves the
following steps:

1. For each signer, a message digest is computed on
the content with a signer-specific message-digest
algorithm. (If two signers employ the same message-digest
algorithm, then the message digest need be computed for
only one of them.) If the signer is authenticating any
information other than the content (see Section 9.2), the
message digest of the content and the other information are
digested with the signer’s message digest algorithm, and
the result becomes the "message digest."

2. For each signer, the message digest and associated
information are encrypted with the signer’s private key.

3. For each signer, the encrypted message digest and
other signer-specific information are collected into a
SignerInfo value, defined in Section 9.2. Certificates and
certificate-revocation lists for each signer, and those not
corresponding to any signer, are collected in this step.

4. The message-digest algorithms for all the signers
and the SignerInfo values for all the signers are collected
together with the content into a SignedData value, defined
in Section 9.1.