1 19 20 package com.maverick.crypto.asn1.x509; 21 22 23 import com.maverick.crypto.asn1.DERBitString; 24 25 42 public class KeyUsage 43 extends DERBitString 44 { 45 public static final int digitalSignature = (1 << 7); 46 public static final int nonRepudiation = (1 << 6); 47 public static final int keyEncipherment = (1 << 5); 48 public static final int dataEncipherment = (1 << 4); 49 public static final int keyAgreement = (1 << 3); 50 public static final int keyCertSign = (1 << 2); 51 public static final int cRLSign = (1 << 1); 52 public static final int encipherOnly = (1 << 0); 53 public static final int decipherOnly = (1 << 15); 54 55 62 public KeyUsage( 63 int usage) 64 { 65 super(getBytes(usage), getPadBits(usage)); 66 } 67 68 public KeyUsage( 69 DERBitString usage) 70 { 71 super(usage.getBytes(), usage.getPadBits()); 72 } 73 74 public String toString() 75 { 76 if (data.length == 1) 77 { 78 return "KeyUsage: 0x" + Integer.toHexString(data[0] & 0xff); 79 } 80 return "KeyUsage: 0x" + Integer.toHexString((data[1] & 0xff) << 8 | (data[0] & 0xff)); 81 } 82 } 83 | Popular Tags |