protected String getFieldAsObjId(EnumType index) { Asn1ObjectIdentifier objId = getFieldAs(index, Asn1ObjectIdentifier.class); if (objId != null) { return objId.getValue(); } return null; }
/** * Create oid * * @param content The hex content * @return The oid * @throws KrbException e */ public static Asn1ObjectIdentifier createOid(String content) throws KrbException { Asn1ObjectIdentifier oid = new Asn1ObjectIdentifier(); oid.useDER(); KrbCodec.decode(HexUtil.hex2bytesFriendly(content), oid); return oid; }
protected void toValue() { StringBuilder sb = new StringBuilder(); byte[] bytes = getBytes(); byte[][] bytesGroups = group(bytes); BigInteger[] coms = convert(bytesGroups); long first = coms[0].longValue(); sb.append(first / 40).append('.'); sb.append(first % 40); if (coms.length > 1) { sb.append('.'); } for (int i = 1; i < coms.length; ++i) { sb.append(coms[i].toString()); if (i != coms.length - 1) { sb.append('.'); } } String value = sb.toString(); setValue(value); }
protected void setFieldAsObjId(EnumType index, String value) { setFieldAs(index, new Asn1ObjectIdentifier(value)); }
private BigInteger[] convert(byte[][] bytesGroups) { BigInteger[] comps = new BigInteger[bytesGroups.length]; for (int i = 0; i < bytesGroups.length; ++i) { comps[i] = convert(bytesGroups[i]); } return comps; }
protected void toValue() { StringBuilder sb = new StringBuilder(); byte[] bytes = getBytes(); byte[][] bytesGroups = group(bytes); BigInteger[] coms = convert(bytesGroups); long first = coms[0].longValue(); sb.append(first / 40).append('.'); sb.append(first % 40); if (coms.length > 1) { sb.append('.'); } for (int i = 1; i < coms.length; ++i) { sb.append(coms[i].toString()); if (i != coms.length - 1) { sb.append('.'); } } String value = sb.toString(); setValue(value); }
protected void setFieldAsObjId(EnumType index, String value) { setFieldAs(index, new Asn1ObjectIdentifier(value)); }
private BigInteger[] convert(byte[][] bytesGroups) { BigInteger[] comps = new BigInteger[bytesGroups.length]; for (int i = 0; i < bytesGroups.length; ++i) { comps[i] = convert(bytesGroups[i]); } return comps; }
protected String getFieldAsObjId(EnumType index) { Asn1ObjectIdentifier objId = getFieldAs(index, Asn1ObjectIdentifier.class); if (objId != null) { return objId.getValue(); } return null; }
/** * Create oid * * @param content The hex content * @return The oid * @throws KrbException e */ public static Asn1ObjectIdentifier createOid(String content) throws KrbException { Asn1ObjectIdentifier oid = new Asn1ObjectIdentifier(); oid.useDER(); KrbCodec.decode(HexUtil.hex2bytesFriendly(content), oid); return oid; }
return new Asn1NumericsString(); case OBJECT_IDENTIFIER: return new Asn1ObjectIdentifier(); case OCTET_STRING: return new Asn1OctetString();
private byte[][] convert(String oid) { String[] parts = oid.split("\\."); BigInteger[] coms = new BigInteger[parts.length - 1]; for (int i = 1; i < parts.length; ++i) { coms[i - 1] = new BigInteger(parts[i]); } coms[0] = coms[0].add(BigInteger.valueOf(Integer.parseInt(parts[0]) * 40)); byte[][] bytesGroups = new byte[coms.length][]; for (int i = 0; i < coms.length; ++i) { bytesGroups[i] = convert(coms[i]); } return bytesGroups; }
public AlgorithmIdentifiers createSupportedCMSTypes() throws KrbException { AlgorithmIdentifiers cmsAlgorithms = new AlgorithmIdentifiers(); AlgorithmIdentifier des3Alg = new AlgorithmIdentifier(); /* krb5_data des3oid = {0, 8, "\x2A\x86\x48\x86\xF7\x0D\x03\x07" };*/ String content = "0x06 08 2A 86 48 86 F7 0D 03 07"; Asn1ObjectIdentifier des3Oid = PkinitCrypto.createOid(content); des3Alg.setAlgorithm(des3Oid.getValue()); cmsAlgorithms.add(des3Alg); return cmsAlgorithms; }
return new Asn1NumericsString(); case OBJECT_IDENTIFIER: return new Asn1ObjectIdentifier(); case OCTET_STRING: return new Asn1OctetString();
private byte[][] convert(String oid) { String[] parts = oid.split("\\."); BigInteger[] coms = new BigInteger[parts.length - 1]; for (int i = 1; i < parts.length; ++i) { coms[i - 1] = new BigInteger(parts[i]); } coms[0] = coms[0].add(BigInteger.valueOf(Integer.parseInt(parts[0]) * 40)); byte[][] bytesGroups = new byte[coms.length][]; for (int i = 0; i < coms.length; ++i) { bytesGroups[i] = convert(coms[i]); } return bytesGroups; }
public AlgorithmIdentifiers createSupportedCMSTypes() throws KrbException { AlgorithmIdentifiers cmsAlgorithms = new AlgorithmIdentifiers(); AlgorithmIdentifier des3Alg = new AlgorithmIdentifier(); /* krb5_data des3oid = {0, 8, "\x2A\x86\x48\x86\xF7\x0D\x03\x07" };*/ String content = "0x06 08 2A 86 48 86 F7 0D 03 07"; Asn1ObjectIdentifier des3Oid = PkinitCrypto.createOid(content); des3Alg.setAlgorithm(des3Oid.getValue()); cmsAlgorithms.add(des3Alg); return cmsAlgorithms; }
Asn1ObjectIdentifier dhOid = PkinitCrypto.createOid(content); AlgorithmIdentifier dhAlg = new AlgorithmIdentifier(); dhAlg.setAlgorithm(dhOid.getValue());
Asn1ObjectIdentifier dhOid = PkinitCrypto.createOid(content); AlgorithmIdentifier dhAlg = new AlgorithmIdentifier(); dhAlg.setAlgorithm(dhOid.getValue());