繁体   English   中英

如何从包含大于 int 最大值的组件的 OID 字符串初始化 ASN1ObjectIdentifier?

[英]How to initialize ASN1ObjectIdentifier from an OID string which contains components larger than int max value?

我正在尝试引用符合{joint-iso-itu-t(2) uuid(25)}弧的未注册 ASN.1 Object 标识符。 我正在使用com.objsys.asn1j.runtime package。

但似乎 asn1rt 库只接受 int[] 作为标识符。 我不能像这样将 OID 字符串的 UUID 组件的值作为 int 传递:

    public Asn1ObjectIdentifier getAttributeOID() {
        
        int[] identifierValue = { 2, 25, singleIntegerValue}; // last part is greater than int max
        return new Asn1ObjectIdentifier(identifierValue);
    }

我尝试使用 objsys.com 文档中解释的解码方法,如下所示:

    public Asn1ObjectIdentifier getAttributeOID() {

        //uuid part is converted to integer value from uuid according to ITU-T X.667 Section 6.3 using 

        String oid = "2.25.142312163956071652603888631318689442116"; 
        Asn1BerDecodeBuffer decodeBuffer = new Asn1BerDecodeBuffer(oid.getBytes(StandardCharsets.UTF_8));
        Asn1ObjectIdentifier asn1ObjectIdentifier = new Asn1ObjectIdentifier();

        try {
            asn1ObjectIdentifier.decode(decodeBuffer, false, oid.length());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        return asn1ObjectIdentifier;
    }

然而,这种方法也没有在结果 object 中为我提供正确的标识符值。它输出如下内容:

  1.10.46.50.53.46.49.52.50.51.49.50.49.54.51.57.53.54.48.55.49.54.53.50.54.48.51.…

我在尝试使用 BouncyCastle 对 object 标识符进行编码然后尝试使用来自com.objsys.asn1j.runtime package 的 api 对其进行解码时也失败了。没用。

Obj-sys 文档显示 OBJECT IDENTIFIER 的 java 映射是一个 int 数组(因此这是一个限制)

我很惊讶你在这里问这个问题,他们有一个联系表

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM