/** * Basic constructor. * * @param usage - the bitwise OR of the Key Usage flags giving the * allowed uses for the key. * e.g. (KeyUsage.keyEncipherment | KeyUsage.dataEncipherment) */ public KeyUsage( int usage) { super(getBytes(usage), getPadBits(usage)); }
protected void validateKeyUsage(int keyUsageBits) throws IOException { Extensions exts = certificate.getTBSCertificate().getExtensions(); if (exts != null) { KeyUsage ku = KeyUsage.fromExtensions(exts); if (ku != null) { int bits = ku.getBytes()[0] & 0xff; if ((bits & keyUsageBits) != keyUsageBits) { throw new TlsFatalAlert(AlertDescription.certificate_unknown); } } } }
static void validateKeyUsage(org.spongycastle.asn1.x509.Certificate c, int keyUsageBits) throws IOException { Extensions exts = c.getTBSCertificate().getExtensions(); if (exts != null) { KeyUsage ku = KeyUsage.fromExtensions(exts); if (ku != null) { int bits = ku.getBytes()[0] & 0xff; if ((bits & keyUsageBits) != keyUsageBits) { throw new TlsFatalAlert(AlertDescription.certificate_unknown); } } } }
private boolean isSuitableKeyUsage(int keyUsageBits, X509Certificate c) { try { Extensions exts = TBSCertificate.getInstance(c.getTBSCertificate()).getExtensions(); if (exts != null) { KeyUsage ku = KeyUsage.fromExtensions(exts); if (ku != null) { int bits = ku.getBytes()[0] & 0xff; if ((bits & keyUsageBits) != keyUsageBits) { return false; } } } } catch (Exception e) { return false; } return true; } }
private boolean isSuitableKeyUsage(int keyUsageBits, X509Certificate c) { try { Extensions exts = TBSCertificate.getInstance(c.getTBSCertificate()).getExtensions(); if (exts != null) { KeyUsage ku = KeyUsage.fromExtensions(exts); if (ku != null) { int bits = ku.getBytes()[0] & 0xff; if ((bits & keyUsageBits) != keyUsageBits) { return false; } } } } catch (Exception e) { return false; } return true; }
protected void validateKeyUsage(int keyUsageBits) throws IOException { Extensions exts; try { exts = TBSCertificate.getInstance(certificate.getTBSCertificate()).getExtensions(); } catch (CertificateEncodingException e) { throw new TlsCryptoException("unable to parse certificate extensions: " + e.getMessage(), e); } if (exts != null) { KeyUsage ku = KeyUsage.fromExtensions(exts); if (ku != null) { int bits = ku.getBytes()[0] & 0xff; if ((bits & keyUsageBits) != keyUsageBits) { throw new TlsFatalAlert(AlertDescription.certificate_unknown); } } } }