@Override public String toString() { StringBuilder buf = new StringBuilder(64); buf.append("[Certificate: type: Key certificate"); if (_payload == null) { buf.append(" null payload"); } else { buf.append("\n\tCrypto type: ").append(getCryptoTypeCode()); buf.append("\n\tSig type: ").append(getSigTypeCode()) .append(" (").append(getSigType()).append(')'); if (_payload.length > HEADER_LENGTH) buf.append("\n\tKey data: ").append(_payload.length - HEADER_LENGTH).append(" bytes"); } buf.append("]"); return buf.toString(); }
/** * Get the portion of this (type 0) SPK that is really padding based on the Key Cert type given, * if any * * @return leading padding length > 0 or null if no padding or type is unknown * @throws IllegalArgumentException if this is already typed to a different type * @since 0.9.12 */ public byte[] getPadding(KeyCertificate kcert) { if (_data == null) throw new IllegalStateException(); SigType newType = kcert.getSigType(); if (_type == newType || newType == null) return null; if (_type != SigType.DSA_SHA1) throw new IllegalStateException("Cannot convert " + _type + " to " + newType); int newLen = newType.getPubkeyLen(); if (newLen >= KEYSIZE_BYTES) return null; int padLen = KEYSIZE_BYTES - newLen; byte[] pad = new byte[padLen]; System.arraycopy(_data, 0, pad, 0, padLen); return pad; }
try { KeyCertificate kc = c.toKeyCertificate(); SigType type = kc.getSigType(); if (type == null || !type.isAvailable() || type.getBaseAlgorithm() == SigAlgo.RSA) { failPermanently(d); try { KeyCertificate kc = c.toKeyCertificate(); SigType type = kc.getSigType(); if (type == null || !type.isAvailable()) { String stype = (type != null) ? type.toString() : Integer.toString(kc.getSigTypeCode());
/** * Signing Key extra data, if any. * * @return null if unset or none * @throws UnsupportedOperationException if the sig type is unsupported */ public byte[] getExtraSigningKeyData() { // we assume no crypto key data if (_payload == null || _payload.length <= HEADER_LENGTH) return null; SigType type = getSigType(); if (type == null) throw new UnsupportedOperationException("unknown sig type"); int extra = Math.max(0, type.getPubkeyLen() - 128); if (_payload.length == HEADER_LENGTH + extra) return getExtraKeyData(); byte[] rv = new byte[extra]; System.arraycopy(_payload, HEADER_LENGTH, rv, 0, extra); return rv; }
/** * @return null if not set or unknown * @since 0.9.17 */ public SigType getSigType() { if (_certificate == null) return null; if (_certificate.getCertificateType() == Certificate.CERTIFICATE_TYPE_KEY) { try { KeyCertificate kcert = _certificate.toKeyCertificate(); return kcert.getSigType(); } catch (DataFormatException dfe) {} } return SigType.DSA_SHA1; }
if (_data == null) throw new IllegalStateException(); SigType newType = kcert.getSigType(); if (_type == newType) return this;
if (cert.getCertificateType() == Certificate.CERTIFICATE_TYPE_KEY) { KeyCertificate kcert = cert.toKeyCertificate(); SigType type = kcert.getSigType(); try { signingKeys = KeyGenerator.getInstance().generateSigningKeys(type); SigType type = kcert.getSigType(); int len = type.getPubkeyLen(); if (len < 128) {