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

Sequence OF #8

Closed
berdyugin opened this issue Aug 24, 2018 · 4 comments
Closed

Sequence OF #8

berdyugin opened this issue Aug 24, 2018 · 4 comments

Comments

@berdyugin
Copy link

Hello,
How to create a Sequence of UTF8String?

$request = new Sequence(
new UTF8String($str)
);
creates a simple Sequence.

Thanks!

@sop
Copy link
Owner

sop commented Aug 24, 2018

Hi!

Could you give an example of what you're trying to encode?

@berdyugin
Copy link
Author

The incoming service parameter is asn:

Msg ::= CHOICE {
request [0] Request,
response [1] Response
}
ResponseRecord ::= SEQUENCE {
number [0] UTF8String,
oper-type [2] INTEGER,
}
Response ::= SEQUENCE OF ResponseRecord
Request ::= SEQUENCE OF UTF8String

I try:

$request = new Sequence(
new UTF8String('77021780117')
);
print(bin2hex($request->toDER()));

//300d0c0b3737303231373830313137
And service can not decode this.

@sop
Copy link
Owner

sop commented Aug 24, 2018

You have to use tagging due to CHOICE. Your full ASN.1 schema should indicate what's the default tagging mode. I'll assume implicit tagging here. Try the following:

$request = new ImplicitlyTaggedType(
    0,
    new Sequence(
        new UTF8String('77021780117')
    )
);

If explicit tagging must be used instead, just replace ImplicitlyTaggedType with ExplicitlyTaggedType.

@berdyugin
Copy link
Author

you are right, thanks

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