如何计算XAdES签名的签名证书的摘要?

时间:2019-07-11 16:56:37

标签: python hash certificate xml-signature

我具有以下X509证书:

MIIIHTCCBwWgAwIBAgIIF947UueTr/4wDQYJKoZIhvcNAQELBQAwgcExCzAJBgNV BAYTAlBUMTMwMQYDVQQKDCpJbnN0aXR1dG8gZG9zIFJlZ2lzdG9zIGUgZG8gTm90 YXJpYWRvIEkuUC4xHDAaBgNVBAsME0NhcnTDo28gZGUgQ2lkYWTDo28xFDASBgNV
      BAsMC3N1YkVDRXN0YWRvMUkwRwYDVQQDDEBFQyBkZSBBc3NpbmF0dXJhIERpZ2l0 YWwgUXVhbGlmaWNhZGEgZG8gQ2FydMOjbyBkZSBDaWRhZMOjbyAwMDE0MB4XDTE4 MDcwOTExNDc1OVoXDTIzMDcwOTIxNTkwMFowggEEMQswCQYDVQQGEwJQVDEcMBoG
      A1UECgwTQ2FydMOjbyBkZSBDaWRhZMOjbzErMCkGA1UECwwiQXNzaW5hdHVyYSBR dWFsaWZpY2FkYSBkbyBDaWRhZMOjbzEcMBoGA1UECwwTQ2lkYWTDo28gUG9ydHVn dcOqczEuMCwGA1UEBAwlRklMSVBFIENBUlZBTEhBSVMgRE9TIFNBTlRPUyBERSBN
      QVRPUzEPMA0GA1UEKgwGTUlHVUVMMRQwEgYDVQQFEwtCSTE1MTYxMTUxMzE1MDMG A1UEAwwsTUlHVUVMIEZJTElQRSBDQVJWQUxIQUlTIERPUyBTQU5UT1MgREUgTUFU T1MwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDBT/YzBGxbpKoufSiJ
      q6YSZ8w8HQurfMTLNz/eFf7F2lAVHhhZZLAnbXHAq4jsKcfc29J1Milq1vImHS/Z W0mxeyFu+FM0PI4VRdrjX/XqewX6e7dGIgBfkCT3EbtozS+m5ABwo6EZE0ZddPty 6Frzv65EI9DkhlKqy0qSUkOLe13su9PhoTLcFaB0dtgYkFgpIXLG6uc4Nxx2Sd44
      DilgHlyYb8nO3o1PzwkC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ryb25pYyBzaWduYXR1cmVzIGFz IGRlZmluZWQgaW4gUmVndWxhdGlvbiAoRVUpIE5vIDkxMC8yMDE0MEoGBgQAjkYB
      BTBAMD4WOGh0dHA6Ly9wa2kuY2FydGFvZGVjaWRhZGFvLnB0L3B1YmxpY28vcG9s aXRpY2FzL2Nwcy5odG1sEwJQVDBpBgNVHR8EYjBgMF6gXKBahlhodHRwOi8vcGtp LmNhcnRhb2RlY2lkYWRhby5wdC9wdWJsaWNvL2xyYy9jY19zdWItZWNfY2lkYWRh
      b19hc3NpbmF0dXJhX2NybDAwMTRfcDAwMDEuY3JsMB0GA1UdDgQWBBQqKpc5DNgY d1GW3eqB4W1D0TCl6jAOBgNVHQ8BAf8EBAMCBkAwDQYJKoZIhvcNAQELBQADggEB ADN1vTH/jAbMrSmXyvd8EtpdMglJYcWf+n1qhZxM4+p+x31vWY75ZhAgSsqH9bK8
      Ll6oE05X3wFMVZKBRI8BkBPWleyvbgK7q9bXGcgS9lmfmlPMuWdfFDmXAd9WOEzb Hu5Tr3rqhlt8sN5vgOl1jzZg7jnPfU/9RQtNqKJm6E/Vwbi5r9KVVFQijULzt92J dTGHzrD3WoCoZfKfZzMsevJW2sSHQAWkJiogckUu5nTv3eARvU8Sfoy5GlNYeYYe
      IbbODsWiD1M5FRqJEsThKEeVgH+ejDQMls897+fYNE/ZAmIiGzjJM4WPR7huGkjH sBBolgg/Rz0cyMmHeejEHzs=

我知道摘要是

2ZXt/8T161gL9mW1UlORjjXBvp/v1gaHausPzeQJiWw=

但是我找不到计算摘要的方法。

修改

我只是不知道要应用哪些数据进行哈希处理。

目标是将摘要放在XAdES签名上,并使用python进行。

1 个答案:

答案 0 :(得分:0)

摘要只是一些数据的哈希值。在您的情况下,我会根据32个字节的长度猜测其为SHA2

该过程预计将要签名的内容散列到所谓的(消息)摘要中,然后使用证书(在您的情况下为RSA)创建摘要的签名。

要回答您的问题(但我找不到计算摘要的方法。):对内容数据使用SHA2。

如果您提供更多详细信息-例如您肯定会使用哪种编程语言一定可以为您提供更多帮助。

编辑

  

我只是不知道要应用哪些数据进行哈希处理。

您要创建签名还是验证签名? 听起来好像您想验证签名。那么,您是否有证书,一些数据和签名-或同时存在?你从哪里来的摘要?如果您告诉我们更多信息,我们可以为您提供进一步的帮助...