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FqFm5swC+gVmm7Atg/zHp0k9v1+oUyshl6YNxINod4i71LcHDZ8tI
USrLXO9yZfcUd6l31yiR9E4U5atIKjGCApcwggKTAgEBMB8wGjELMAkGA1UEBhMC
VVMxCzAJBgNVBAoMAlo0AgEBMA0GCWCGSAFlAwQCAQUAoIIBSTAYBgkqhkiG9w0B
CQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0xNTA3MjIwMjUyMzVaMC8G
CSqGSIb3DQEJBDEiBCCYNIdtz7BcsWelwklT66WMSsibGt9X8o8vnQmvEH7o8DA6
BgsqhkiG9w0BCRACDzErMCkGBCoDBAUwITAJBgUrDgMCGgUABBShoqOkpaanqKmg
oaKjpKWmp6ipoDBKBgsqhkiG9w0BCRACDDE7MDkwNwQUdsGdeHdBva92yrHELRZs
tTaqg/gwHzAaMQswCQYDVQQGEwJVUzELMAkGA1UECgwCWjQCAQEwVgYLKoZIhvcN
AQkQAi8xRzBFMEMEIMNV3E7h3KKpUFPtkNJ/8TAlyIeCTafXzIM0irKg6URCMB8w
GjELMAkGA1UEBhMCVVMxCzAJBgNVBAoMAlo0AgEBMA0GCSqGSIb3DQEBCwUABIIB
ANW+XgUsuYk1rul2Ws6m9PSrvQeWcK+b8Rg8tvsYN3k4rGrI4i/Vzl880oX3vIX7
r8Q8v4WZ+QxmgnBD+0PFqET/wkHBWYPRx6KthiKnz8dY3cakK5UorJebAkaamBB0
LUIFsTQlNB+bw1N9jHwGg9pdGgsBMB0ZGJkv9qfzfeNaIIo2TkOWHOHEGp+iQ+4V
J10wYE72K16Z5ylNKS980azGLdWSA2B1NlRsf0DrxZNLH6jFDAGrQtiuhcYs7/+R
8Rx+ISPa3YC/E813LKBjNdTMvGnxoPUrsc22MPRUb4Sj3+NthZO42aUqXwGfLLE/
zpbC9FnUYduAn/1XrFpv4sw=
如果你通过openssl asn1parse -in cms.txt
(其中cms.txt包含上面的内容)运行它,你会发现它有OID代表sha256这样的东西。与sha256对应的OID为2.16.840.1.101.3.4.2.1。
我的问题是......在OpenSSL来源中,这种关联的来源是什么?
就是这样:
https://android.googlesource.com/platform/external/openssl/+/master/crypto/objects/objects.h
这似乎定义了一堆OID,但sha256不在其中,因此我不清楚它的定义位置。
有什么想法吗?
答案 0 :(得分:3)
OID在 crypto/objects/objects.txt
中定义。此文件的语法在crypto/objects/objects.README
中定义,并由crypto/objects/objects.pl
脚本转换为头文件。
因此定义了NIST SHA-2 OID:
# OIDs for SHA224, SHA256, SHA385 and SHA512, according to x9.84.
!Alias nist_hashalgs nistAlgorithms 2
nist_hashalgs 1 : SHA256 : sha256
nist_hashalgs 2 : SHA384 : sha384
nist_hashalgs 3 : SHA512 : sha512
nist_hashalgs 4 : SHA224 : sha224
nistAlgorithms
前缀在文件前面定义:
!Alias csor 2 16 840 1 101 3
!Alias nistAlgorithms csor 4
组合,这些为您发布的ASN.1中显示的SHA-256提供了完整的OID:2.16.840.1.101.3.4.2.1
。