Parse ASN.1 encoding using Java
How can I read an ASN.1 file using Java when the file has this syntax:
Tagged[6]IMPLICIT
Sequence
Tagged[0]IMPLICIT
OCTET STRING[3](UGW)
Tagged[1]IMPLICIT
OCTET STRING[5](nair1)
Tagged[3]IMPLICIT
OCTET STRING[13](6430408182034)
Tagged[5]IMPLICIT
OCTET STRING[19](201211113336+0300)
Tagged[6]IMPLIIT
OCTET STRING[5](nair1)
java file parsing encoding asn1
migrated from security.stackexchange.com Sep 17 '18 at 15:04
This question came from our site for information security professionals.
add a comment |
How can I read an ASN.1 file using Java when the file has this syntax:
Tagged[6]IMPLICIT
Sequence
Tagged[0]IMPLICIT
OCTET STRING[3](UGW)
Tagged[1]IMPLICIT
OCTET STRING[5](nair1)
Tagged[3]IMPLICIT
OCTET STRING[13](6430408182034)
Tagged[5]IMPLICIT
OCTET STRING[19](201211113336+0300)
Tagged[6]IMPLIIT
OCTET STRING[5](nair1)
java file parsing encoding asn1
migrated from security.stackexchange.com Sep 17 '18 at 15:04
This question came from our site for information security professionals.
While ASN.1 is related to security, your question is not a security question as it is entirely about programming.
– AndrolGenhald
Sep 17 '18 at 13:32
actually i am about to program a stream mediation system so, my first step is to try and parse this code into java program security will be encluded in the next steps.
– M.Kamal
Sep 17 '18 at 13:34
1
Then feel free to ask a new question when you get to the next steps :) -- I agree with Androl that this question is purely programming. I'm voting to migrate to Stack Overflow where you'll get a better answer.
– Mike Ounsworth
Sep 17 '18 at 13:49
@MikeOunsworth thanks for your advice i will do so.
– M.Kamal
Sep 17 '18 at 17:51
add a comment |
How can I read an ASN.1 file using Java when the file has this syntax:
Tagged[6]IMPLICIT
Sequence
Tagged[0]IMPLICIT
OCTET STRING[3](UGW)
Tagged[1]IMPLICIT
OCTET STRING[5](nair1)
Tagged[3]IMPLICIT
OCTET STRING[13](6430408182034)
Tagged[5]IMPLICIT
OCTET STRING[19](201211113336+0300)
Tagged[6]IMPLIIT
OCTET STRING[5](nair1)
java file parsing encoding asn1
How can I read an ASN.1 file using Java when the file has this syntax:
Tagged[6]IMPLICIT
Sequence
Tagged[0]IMPLICIT
OCTET STRING[3](UGW)
Tagged[1]IMPLICIT
OCTET STRING[5](nair1)
Tagged[3]IMPLICIT
OCTET STRING[13](6430408182034)
Tagged[5]IMPLICIT
OCTET STRING[19](201211113336+0300)
Tagged[6]IMPLIIT
OCTET STRING[5](nair1)
java file parsing encoding asn1
java file parsing encoding asn1
edited Sep 17 '18 at 17:55
M.Kamal
asked Sep 17 '18 at 13:27
M.KamalM.Kamal
11
11
migrated from security.stackexchange.com Sep 17 '18 at 15:04
This question came from our site for information security professionals.
migrated from security.stackexchange.com Sep 17 '18 at 15:04
This question came from our site for information security professionals.
While ASN.1 is related to security, your question is not a security question as it is entirely about programming.
– AndrolGenhald
Sep 17 '18 at 13:32
actually i am about to program a stream mediation system so, my first step is to try and parse this code into java program security will be encluded in the next steps.
– M.Kamal
Sep 17 '18 at 13:34
1
Then feel free to ask a new question when you get to the next steps :) -- I agree with Androl that this question is purely programming. I'm voting to migrate to Stack Overflow where you'll get a better answer.
– Mike Ounsworth
Sep 17 '18 at 13:49
@MikeOunsworth thanks for your advice i will do so.
– M.Kamal
Sep 17 '18 at 17:51
add a comment |
While ASN.1 is related to security, your question is not a security question as it is entirely about programming.
– AndrolGenhald
Sep 17 '18 at 13:32
actually i am about to program a stream mediation system so, my first step is to try and parse this code into java program security will be encluded in the next steps.
– M.Kamal
Sep 17 '18 at 13:34
1
Then feel free to ask a new question when you get to the next steps :) -- I agree with Androl that this question is purely programming. I'm voting to migrate to Stack Overflow where you'll get a better answer.
– Mike Ounsworth
Sep 17 '18 at 13:49
@MikeOunsworth thanks for your advice i will do so.
– M.Kamal
Sep 17 '18 at 17:51
While ASN.1 is related to security, your question is not a security question as it is entirely about programming.
– AndrolGenhald
Sep 17 '18 at 13:32
While ASN.1 is related to security, your question is not a security question as it is entirely about programming.
– AndrolGenhald
Sep 17 '18 at 13:32
actually i am about to program a stream mediation system so, my first step is to try and parse this code into java program security will be encluded in the next steps.
– M.Kamal
Sep 17 '18 at 13:34
actually i am about to program a stream mediation system so, my first step is to try and parse this code into java program security will be encluded in the next steps.
– M.Kamal
Sep 17 '18 at 13:34
1
1
Then feel free to ask a new question when you get to the next steps :) -- I agree with Androl that this question is purely programming. I'm voting to migrate to Stack Overflow where you'll get a better answer.
– Mike Ounsworth
Sep 17 '18 at 13:49
Then feel free to ask a new question when you get to the next steps :) -- I agree with Androl that this question is purely programming. I'm voting to migrate to Stack Overflow where you'll get a better answer.
– Mike Ounsworth
Sep 17 '18 at 13:49
@MikeOunsworth thanks for your advice i will do so.
– M.Kamal
Sep 17 '18 at 17:51
@MikeOunsworth thanks for your advice i will do so.
– M.Kamal
Sep 17 '18 at 17:51
add a comment |
1 Answer
1
active
oldest
votes
ASN.1 definition of yours looks mistaken. I would suggest correcting it as below :
My-Schema DEFINITIONS IMPLICIT TAGS ::=
BEGIN
MySequence ::= SEQUENCE
{
str1 OCTET STRING (SIZE(1..50)),
str2 OCTET STRING (SIZE(1..50)),
str3 OCTET STRING (SIZE(1..50)),
str4 OCTET STRING (SIZE(1..50)),
str5 OCTET STRING (SIZE(1..50))
}
END
It can be easily encoded using bountycastle ASN.1 API
import org.bouncycastle.asn1.*;
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(new DEROctetString("str1".getBytes()));
v.add(new DEROctetString("str2".getBytes()));
v.add(new DEROctetString("str3".getBytes()));
v.add(new DEROctetString("str4".getBytes()));
byte encoded = new DERSequence(v).getEncoded();
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52370719%2fparse-asn-1-encoding-using-java%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
ASN.1 definition of yours looks mistaken. I would suggest correcting it as below :
My-Schema DEFINITIONS IMPLICIT TAGS ::=
BEGIN
MySequence ::= SEQUENCE
{
str1 OCTET STRING (SIZE(1..50)),
str2 OCTET STRING (SIZE(1..50)),
str3 OCTET STRING (SIZE(1..50)),
str4 OCTET STRING (SIZE(1..50)),
str5 OCTET STRING (SIZE(1..50))
}
END
It can be easily encoded using bountycastle ASN.1 API
import org.bouncycastle.asn1.*;
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(new DEROctetString("str1".getBytes()));
v.add(new DEROctetString("str2".getBytes()));
v.add(new DEROctetString("str3".getBytes()));
v.add(new DEROctetString("str4".getBytes()));
byte encoded = new DERSequence(v).getEncoded();
add a comment |
ASN.1 definition of yours looks mistaken. I would suggest correcting it as below :
My-Schema DEFINITIONS IMPLICIT TAGS ::=
BEGIN
MySequence ::= SEQUENCE
{
str1 OCTET STRING (SIZE(1..50)),
str2 OCTET STRING (SIZE(1..50)),
str3 OCTET STRING (SIZE(1..50)),
str4 OCTET STRING (SIZE(1..50)),
str5 OCTET STRING (SIZE(1..50))
}
END
It can be easily encoded using bountycastle ASN.1 API
import org.bouncycastle.asn1.*;
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(new DEROctetString("str1".getBytes()));
v.add(new DEROctetString("str2".getBytes()));
v.add(new DEROctetString("str3".getBytes()));
v.add(new DEROctetString("str4".getBytes()));
byte encoded = new DERSequence(v).getEncoded();
add a comment |
ASN.1 definition of yours looks mistaken. I would suggest correcting it as below :
My-Schema DEFINITIONS IMPLICIT TAGS ::=
BEGIN
MySequence ::= SEQUENCE
{
str1 OCTET STRING (SIZE(1..50)),
str2 OCTET STRING (SIZE(1..50)),
str3 OCTET STRING (SIZE(1..50)),
str4 OCTET STRING (SIZE(1..50)),
str5 OCTET STRING (SIZE(1..50))
}
END
It can be easily encoded using bountycastle ASN.1 API
import org.bouncycastle.asn1.*;
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(new DEROctetString("str1".getBytes()));
v.add(new DEROctetString("str2".getBytes()));
v.add(new DEROctetString("str3".getBytes()));
v.add(new DEROctetString("str4".getBytes()));
byte encoded = new DERSequence(v).getEncoded();
ASN.1 definition of yours looks mistaken. I would suggest correcting it as below :
My-Schema DEFINITIONS IMPLICIT TAGS ::=
BEGIN
MySequence ::= SEQUENCE
{
str1 OCTET STRING (SIZE(1..50)),
str2 OCTET STRING (SIZE(1..50)),
str3 OCTET STRING (SIZE(1..50)),
str4 OCTET STRING (SIZE(1..50)),
str5 OCTET STRING (SIZE(1..50))
}
END
It can be easily encoded using bountycastle ASN.1 API
import org.bouncycastle.asn1.*;
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(new DEROctetString("str1".getBytes()));
v.add(new DEROctetString("str2".getBytes()));
v.add(new DEROctetString("str3".getBytes()));
v.add(new DEROctetString("str4".getBytes()));
byte encoded = new DERSequence(v).getEncoded();
edited Jan 10 at 14:43
answered Jan 1 at 7:03
Kemal AtikKemal Atik
5715
5715
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52370719%2fparse-asn-1-encoding-using-java%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
While ASN.1 is related to security, your question is not a security question as it is entirely about programming.
– AndrolGenhald
Sep 17 '18 at 13:32
actually i am about to program a stream mediation system so, my first step is to try and parse this code into java program security will be encluded in the next steps.
– M.Kamal
Sep 17 '18 at 13:34
1
Then feel free to ask a new question when you get to the next steps :) -- I agree with Androl that this question is purely programming. I'm voting to migrate to Stack Overflow where you'll get a better answer.
– Mike Ounsworth
Sep 17 '18 at 13:49
@MikeOunsworth thanks for your advice i will do so.
– M.Kamal
Sep 17 '18 at 17:51