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

Can't write explicitly tagged sets #8

Closed
jethrogb opened this issue Apr 18, 2017 · 2 comments
Closed

Can't write explicitly tagged sets #8

jethrogb opened this issue Apr 18, 2017 · 2 comments

Comments

@jethrogb
Copy link
Contributor

I don't think it's possible to generate the following with yasna right now:

$ openssl asn1parse -i
-----BEGIN CERTIFICATE REQUEST-----
MIIC1zCCAb8CAQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUx
ITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDCCASIwDQYJKoZIhvcN
AQEBBQADggEPADCCAQoCggEBALZ0OBVVnPy76be52VkLNzHFKFTvBT2cwvQhlR3y
ryy9k3mzFH7tDxxFiqhvDrpaK7emYwoRuXspp/DZAElYVv7RNgnjQwuDjUoYtlcq
mDEaAP0N021myHqyDMRo1AVzta7suGZ9Zv9JY2pWA+nkYrI51KP18ixcGbga1E6W
VgZ79VBCoebC/zs61wjtCcRWV8O0XH6V8J5vuwG51D8ZYIIczg40dGidZ8R0TqM/
b7Rp747hGYB4nE4khWFn+dgyRbQuF9wOxVUbm/eG516KivXHxsXtA7hpyqm7s13C
ucER2XOUJfp/ks78l4JY09Vz9joa1fNp5dqbTjfstf7zfW8CAwEAAaBNMBAGCSqG
SIb3DQEJAjEDDAF4MBAGCSqGSIb3DQEJBzEDDAF4MCcGCSqGSIb3DQEJDjEaMBgw
CQYDVR0TBAIwADALBgNVHQ8EBAMCBeAwDQYJKoZIhvcNAQELBQADggEBAFntX9+6
UxtHFd/XrIFA8IoN7o9Q6RE6lMGy6fvQ8cpeorhnaJs92VcF95q22lLl4HrDgGYq
vsXzS9OBW1EDwp56JKo5CC0M5tBTKEdqAuhdoeyb7aliHSzpACycmgZx+M0BHcEi
XuaceP+lTd+u7N6qXvKIK+Zeayb6lPcsFG+Pna5EZ0se1pGcLPTAHAMTYOOKntZp
PYJp7G3BOpg1Q7FMiLpcCGpTV2ibfJm09gsb1AVazYWMhRixY6xA2+He3TdSt53M
S/WaUMug/FVcqJwirJt65ZuROgNZY9ATaD9bu69ALA0BCkyu7/1hoRMLKrqGEc9W
J+Dby82v7utsHFI=
-----END CERTIFICATE REQUEST-----
    0:d=0  hl=4 l= 727 cons: SEQUENCE          
    4:d=1  hl=4 l= 447 cons:  SEQUENCE          
    8:d=2  hl=2 l=   1 prim:   INTEGER           :00
   11:d=2  hl=2 l=  69 cons:   SEQUENCE          
   13:d=3  hl=2 l=  11 cons:    SET               
   15:d=4  hl=2 l=   9 cons:     SEQUENCE          
   17:d=5  hl=2 l=   3 prim:      OBJECT            :countryName
   22:d=5  hl=2 l=   2 prim:      PRINTABLESTRING   :AU
   26:d=3  hl=2 l=  19 cons:    SET               
   28:d=4  hl=2 l=  17 cons:     SEQUENCE          
   30:d=5  hl=2 l=   3 prim:      OBJECT            :stateOrProvinceName
   35:d=5  hl=2 l=  10 prim:      UTF8STRING        :Some-State
   47:d=3  hl=2 l=  33 cons:    SET               
   49:d=4  hl=2 l=  31 cons:     SEQUENCE          
   51:d=5  hl=2 l=   3 prim:      OBJECT            :organizationName
   56:d=5  hl=2 l=  24 prim:      UTF8STRING        :Internet Widgits Pty Ltd
   82:d=2  hl=4 l= 290 cons:   SEQUENCE          
   86:d=3  hl=2 l=  13 cons:    SEQUENCE          
   88:d=4  hl=2 l=   9 prim:     OBJECT            :rsaEncryption
   99:d=4  hl=2 l=   0 prim:     NULL              
  101:d=3  hl=4 l= 271 prim:    BIT STRING        
  376:d=2  hl=2 l=  77 cons:   cont [ 0 ]        
  378:d=3  hl=2 l=  16 cons:    SEQUENCE          
  380:d=4  hl=2 l=   9 prim:     OBJECT            :unstructuredName
  391:d=4  hl=2 l=   3 cons:     SET               
  393:d=5  hl=2 l=   1 prim:      UTF8STRING        :x
  396:d=3  hl=2 l=  16 cons:    SEQUENCE          
  398:d=4  hl=2 l=   9 prim:     OBJECT            :challengePassword
  409:d=4  hl=2 l=   3 cons:     SET               
  411:d=5  hl=2 l=   1 prim:      UTF8STRING        :x
  414:d=3  hl=2 l=  39 cons:    SEQUENCE          
  416:d=4  hl=2 l=   9 prim:     OBJECT            :Extension Request
  427:d=4  hl=2 l=  26 cons:     SET               
  429:d=5  hl=2 l=  24 cons:      SEQUENCE          
  431:d=6  hl=2 l=   9 cons:       SEQUENCE          
  433:d=7  hl=2 l=   3 prim:        OBJECT            :X509v3 Basic Constraints
  438:d=7  hl=2 l=   2 prim:        OCTET STRING      [HEX DUMP]:3000
  442:d=6  hl=2 l=  11 cons:       SEQUENCE          
  444:d=7  hl=2 l=   3 prim:        OBJECT            :X509v3 Key Usage
  449:d=7  hl=2 l=   4 prim:        OCTET STRING      [HEX DUMP]:030205E0
  455:d=1  hl=2 l=  13 cons:  SEQUENCE          
  457:d=2  hl=2 l=   9 prim:   OBJECT            :sha256WithRSAEncryption
  468:d=2  hl=2 l=   0 prim:   NULL              
  470:d=1  hl=4 l= 257 prim:  BIT STRING        

At offset 376 is a [0] SET OF SEQUENCE { ... }, see https://tools.ietf.org/html/rfc2986#section-4. DERWriter::write_tagged has a callback with a DERWriter, not DERWriterSeq or DERWriterSet, so I don't see how to emit the multiple sequences in the set.

@qnighy
Copy link
Owner

qnighy commented Apr 20, 2017

Isn't this an implicit tag (declared as DEFINITIONS IMPLICIT TAGS ::= in the RFC), for which yasna has a corresponding API write_tagged_implicit?

@jethrogb
Copy link
Contributor Author

Yes, you're right. Solution:

w.write_tagged_implicit(|w|w.write_set(|w|
  for _ in ... {
    writer.next().write_...(...)
  }
));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants