Skip to content

Loading…

Degenerate PKCS7 + split OctetString test cases #22

Open
wants to merge 1 commit into from

1 participant

@matthauck

I didn't know how to connect this to pull request #9... but that is what these test cases are intended for.

@matthauck

Any hope of these two pull requests getting pulled in before jruby-openssl merges entirely with jruby? That would make maintaining this fork a little tricky and prevent upgrade to jruby 1.7... =(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 5, 2012
  1. @matthauck

    Degenerate PKCS7 + split OctetString test cases

    matthauck committed
    For pull request #9
This page is out of date. Refresh to see the latest.
Showing with 86 additions and 0 deletions.
  1. +86 −0 test/test_pkcs7.rb
View
86 test/test_pkcs7.rb
@@ -53,4 +53,90 @@ def test_load_empty_pkcs7
p7 = OpenSSL::PKCS7.new(EMPTY_PEM)
assert_equal(EMPTY_PEM, p7.to_pem)
end
+
+ PKCS7_ENCODED = <<END
+MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEH
+AaCAJIAEggNDMIAGCSqGSIb3DQEHA6CAMIACAQAxge8wgewCAQAwVTBPMQ0w
+CwYDVQQKDAROb25lMT4wPAYDVQQDDDVtaGF1Y2sgUm9vdCBDQSAoMjc3YWYy
+YjMtYWMzZC00YjUzLTg4YzItOGMxOWYzZTY5YWE3KQICAgkwDQYJKoZIhvcN
+AQEBBQAEgYBO/v799CxX01nBuOE0HbQlJeZY9DD0dcpyss8C7rqLwuAbNf5F
+Ctb63amW/If8MgCFYTZoQgbleDugJBEGDa6+9t/VYivPX4E4Gy8lwn5giQsC
+E4O17Xj2w9Dnina5YlaSWFX16rCRXFJcGnRtAh37luM8hBVlhvtTEIGzO7pG
+mzCABgkqhkiG9w0BBwEwFAYIKoZIhvcNAwcECBwGOYbO/8iyoIAEggIAE5fd
+HnQILZOp1jOg0lU3ycXNew+6O75htpilXT7WsMXWR/veFbN+FfC1QjzjC5jj
+Ze7JqJ5cCP7jYQJ5sUFED6xU+m2iB4Tp8akCW4solC7bn3tbqVLYZeI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ICAgkwDQYJKoZIhvcNAQEBBQAEgYBO/v79
+9CxX01nBuOE0HbQlJeZY9DD0dcpyss8C7rqLwuAbNf5FCtb63amW/If8MgCFYTZo
+QgbleDugJBEGDa6+9t/VYivPX4E4Gy8lwn5giQsCE4O17Xj2w9Dnina5YlaSWFX1
+6rCRXFJcGnRtAh37luM8hBVlhvtTEIGzO7pGmzCCAi0GCSqGSIb3DQEHATAUBggq
+hkiG9w0DBwQIHAY5hs7/yLKAggIIE5fdHnQILZOp1jOg0lU3ycXNew+6O75htpil
+XT7WsMXWR/veFbN+FfC1QjzjC5jjZe7JqJ5cCP7jYQJ5sUFED6xU+m2iB4Tp8akC
+W4solC7bn3tbqVLYZeIGeP1YlCAswysgFNX+SQixkXYRi6Hpjr3VsNcqBPgtSxMF
+1thPJDJH0IctIWPjsY1yYU75vsNpW5H4XdaPyhb7L9PH8EFwjZGHs13SjRI2QHN2
+jv818+0jMisEfRV0NOKZC7GAc2fiZEfnOclfs0CByS5TbkfRXSIXffDevGrf6xDl
+dCnSlj5/BrxVvKpWmsIaZBzOMlVYOLbGdNKCiWabX4tEN2ZI3G5Cl9HXkvsJD0Yy
+fws9Hm+kS8bieL89AsgOkcraF1/ovvYFb+j1LggsyGggvc8g8sChOMyaej/GHzdF
++ITeQ4JSKP2ULVkgnZw3BAsQkgKYSfX9vX2QGGkIdu4B/RUkT4/zLEzpsrPr6YI2
+NO+pz19Ye4ixQHEjAq1A2/d3JAlPK7ilm1LsyoMxte0Z3YT3UL1x/I7eukeoRZWf
+VTK6eWEOvI2y/Lb4TH9LCTWG9yzohC/I27FyDU2WO/DbuxNxHSisSAe8nRn/qu7l
+Aa4i9hQhM9yCAzfCDcape1q7KAGMmDfEsHHl4dPgEStD9BD+kjRk9/7VwesBGk1R
+Eenz/1izVP8HhRKhww==
+-----END PKCS7-----
+END
+
+ def test_signed_pkcs7_octet_sequence
+ p7signed = OpenSSL::PKCS7.new(PKCS7_ENCODED.unpack('m*').first)
+ p7signed.verify(nil, OpenSSL::X509::Store.new, nil, OpenSSL::PKCS7::NOVERIFY)
+
+ p7 = OpenSSL::PKCS7.new(p7signed.data)
+
+ assert_equal(p7.to_pem, PKCS7_DECODED)
+ end
+
+ def test_degenerate_pkcs7_add_cert
+ p7 = OpenSSL::PKCS7.new
+ cert = OpenSSL::X509::Certificate.new(CERT_PEM)
+ p7.type = 'signed'
+
+ assert_nothing_raised do
+ p7.add_certificate(cert)
+ end
+ end
end
Something went wrong with that request. Please try again.