ASN1C DER 解码器

发布于 2025-01-08 04:20:04 字数 1100 浏览 3 评论 0 原文

我正在尝试创建简单的 DER 解码器 - 控制台应用程序,仅输出给定数据结构的内容(以 DER 格式编码,例如 这个)。

我在运行此示例时遇到问题: A ''矩形'' 解码器

我正在尝试使用 MSVC 编译它,但在 #include #include 方面遇到问题。此外,类型 ssize_t 未定义。

这是我现在所做的:
1. 在 Online ASN.1 Compiler 中,我将此代码粘贴到文本字段中:

RectangleModule1 DEFINITIONS ::=
BEGIN

Rectangle ::= SEQUENCE {
    height  INTEGER,
    width   INTEGER
}

END

2. 我选择了 “使用本机机器类型”“生成 PER 支持”选项。
3.它“编译正常”,所以我下载了该输出.tgz
4. 在 Visual Studio 2010 中创建空项目,拖放从此 .tgz
提取的源文件 5. 将附加包含目录设置为ASN1C的“骨骼”目录
6. 尝试构建它。

我缺少什么?

任何帮助将不胜感激

I'm trying to create simple DER decoder - console application that just outputs content of given data structure (encoded in DER format, like this one).

I have problems with running this example: A ''Rectangle'' Decoder .

I'm trying to compile it with MSVC and I have problems with #include <inttypes.h> and #include <netinet/in.h>. Also type ssize_t is undefined.

Here's what I've done for now:
1. At Online ASN.1 Compiler I pasted this code into textfield:

RectangleModule1 DEFINITIONS ::=
BEGIN

Rectangle ::= SEQUENCE {
    height  INTEGER,
    width   INTEGER
}

END

2. I selected "Use native machine types" and "Generate PER support" options.
3. It "Compiled OK" so I downloaded that output .tgz
4. Created empty project int Visual Studio 2010, drag-n-dropped source files extracted from this .tgz
5. Set additional include directory to "skeletons" directory of ASN1C
6. Tried to build it.

What am I missing?

Any help would be appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

草莓味的萝莉 2025-01-15 04:20:04

问题是ASN1C生成的代码必须修改才能用MSVC编译并在Windows环境中使用。

  1. #include 应替换为 #define ssize_t SSIZE_T
  2. #include 应替换带有 #include
  3. 关键字的 inline 应从定义在中的 static 函数中删除asn_internal.h

之后,一切正常;)

The problem is that code generated by ASN1C must be modified in order to compile it with MSVC and to use it in Windows environment.

  1. #include <inttypes.h> should be replaced with #define ssize_t SSIZE_T
  2. #include <netinet/in.h> should be replaced with #include <Winsock2.h>
  3. keyword inline should be removed from static functions defined in asn_internal.h

After that, everything works fine ;)

嗼ふ静 2025-01-15 04:20:04

确保您有正确的 ASN 定义文件。然后转到链接
http://lionet.info/asn1c/asn1c.cgi

将您的 ASN 定义粘贴到给定窗口中。按“继续 ASN.1 编译”按钮。如果出现任何编译错误,请纠正这些错误。编译成功后,它将生成解码器的代码。尝试一下它的好处。

Make sure that you have a correct ASN defintion file. Then go to link
http://lionet.info/asn1c/asn1c.cgi

paste your ASN definition in the given window. Press the button "Proceed with ASN.1 compilation". If you get any compilation error rectify those. After the compilation is successful it will generate the code for your decoder. Give it a try its good.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文