1 package org.bouncycastle.asn1.x509;
3 import org.bouncycastle.asn1.*;
7 * id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 }
9 * KeyUsage ::= BIT STRING {
10 * digitalSignature (0),
12 * keyEncipherment (2),
13 * dataEncipherment (3),
24 public static final int digitalSignature = (1 << 7);
25 public static final int nonRepudiation = (1 << 6);
26 public static final int keyEncipherment = (1 << 5);
27 public static final int dataEncipherment = (1 << 4);
28 public static final int keyAgreement = (1 << 3);
29 public static final int keyCertSign = (1 << 2);
30 public static final int cRLSign = (1 << 1);
31 public static final int encipherOnly = (1 << 0);
32 public static final int decipherOnly = (1 << 15);
34 static private byte[] getUsageBytes(
37 byte[] usageBytes = new byte[2];
39 usageBytes[0] = (byte)(usage & 0xFF);
40 usageBytes[1] = (byte)((usage >> 8) & 0xFF);
48 * @param usage - the bitwise OR of the Key Usage flags giving the
49 * allowed uses for the key.
50 * e.g. (X509KeyUsage.keyEncipherment | X509KeyUsage.dataEncipherment)
55 super(getUsageBytes(usage), 7);
61 super(usage.getBytes(), usage.getPadBits());
64 public String toString()
66 return "KeyUsage: 0x" + Integer.toHexString(data[0] & 0xff);