gluu
静的公開メンバ関数 | 全メンバ一覧
org.xdi.oxauth.model.jwe.KeyDerivationFunction クラス
org.xdi.oxauth.model.jwe.KeyDerivationFunction 連携図
Collaboration graph

静的公開メンバ関数

static byte [] generateCek (byte[] cmk, BlockEncryptionAlgorithm blockEncryptionAlgorithm) throws UnsupportedEncodingException, NoSuchProviderException, NoSuchAlgorithmException, InvalidParameterException
 
static byte [] generateCik (byte[] cmk, BlockEncryptionAlgorithm blockEncryptionAlgorithm) throws UnsupportedEncodingException, NoSuchProviderException, NoSuchAlgorithmException, InvalidParameterException
 

詳解

著者
Javier Rojas Blum
バージョン
July 31, 2016

関数詳解

◆ generateCek()

static byte [] org.xdi.oxauth.model.jwe.KeyDerivationFunction.generateCek ( byte []  cmk,
BlockEncryptionAlgorithm  blockEncryptionAlgorithm 
) throws UnsupportedEncodingException, NoSuchProviderException, NoSuchAlgorithmException, InvalidParameterException
inlinestatic
28  {
29  if (cmk == null) {
30  throw new InvalidParameterException("The content master key (CMK) is null");
31  }
32  if (blockEncryptionAlgorithm == null) {
33  throw new InvalidParameterException("The block encryption algorithm is null");
34  }
35  if (blockEncryptionAlgorithm != BlockEncryptionAlgorithm.A128CBC_PLUS_HS256
36  && blockEncryptionAlgorithm != BlockEncryptionAlgorithm.A256CBC_PLUS_HS512) {
37  throw new InvalidParameterException("The block encryption algorithm is not supported");
38  }
39 
40  byte[] round1 = Base64Util.unsignedToBytes(new int[]{0, 0, 0, 1});
41  byte[] outputBitSize = null;
42  if (blockEncryptionAlgorithm != BlockEncryptionAlgorithm.A128CBC_PLUS_HS256) {
43  outputBitSize = Base64Util.unsignedToBytes(new int[]{0, 0, 0, 128});
44  } else { //A256CBC_PLUS_HS512
45  outputBitSize = Base64Util.unsignedToBytes(new int[]{0, 0, 1, 0});
46  }
47  byte[] encValue = blockEncryptionAlgorithm.getName().getBytes(Util.UTF8_STRING_ENCODING);
48  byte[] epu = Base64Util.unsignedToBytes(new int[]{0, 0, 0, 0});
49  byte[] epv = Base64Util.unsignedToBytes(new int[]{0, 0, 0, 0});
50  byte[] label = "Encryption".getBytes(Util.UTF8_STRING_ENCODING);
51  byte[] round1Input = ArrayUtils.addAll(round1, cmk);
52  round1Input = ArrayUtils.addAll(round1Input, outputBitSize);
53  round1Input = ArrayUtils.addAll(round1Input, encValue);
54  round1Input = ArrayUtils.addAll(round1Input, epu);
55  round1Input = ArrayUtils.addAll(round1Input, epv);
56  round1Input = ArrayUtils.addAll(round1Input, label);
57 
58  MessageDigest mda = MessageDigest.getInstance(blockEncryptionAlgorithm.getMessageDiggestAlgorithm(), "BC");
59  byte[] round1Hash = mda.digest(round1Input);
60  byte[] cek = Arrays.copyOf(round1Hash, blockEncryptionAlgorithm.getCekLength() / 8);
61 
62  return cek;
63  }

◆ generateCik()

static byte [] org.xdi.oxauth.model.jwe.KeyDerivationFunction.generateCik ( byte []  cmk,
BlockEncryptionAlgorithm  blockEncryptionAlgorithm 
) throws UnsupportedEncodingException, NoSuchProviderException, NoSuchAlgorithmException, InvalidParameterException
inlinestatic
66  {
67  if (cmk == null) {
68  throw new InvalidParameterException("The content master key (CMK) is null");
69  }
70  if (blockEncryptionAlgorithm == null) {
71  throw new InvalidParameterException("The block encryption algorithm is null");
72  }
73  if (blockEncryptionAlgorithm != BlockEncryptionAlgorithm.A128CBC_PLUS_HS256
74  && blockEncryptionAlgorithm != BlockEncryptionAlgorithm.A256CBC_PLUS_HS512) {
75  throw new InvalidParameterException("The block encryption algorithm is not supported");
76  }
77 
78  byte[] round1 = Base64Util.unsignedToBytes(new int[]{0, 0, 0, 1});
79  byte[] outputBitSize = null;
80  if (blockEncryptionAlgorithm != BlockEncryptionAlgorithm.A128CBC_PLUS_HS256) {
81  outputBitSize = Base64Util.unsignedToBytes(new int[]{0, 0, 1, 0});
82  } else { //A256CBC_PLUS_HS512
83  outputBitSize = Base64Util.unsignedToBytes(new int[]{0, 0, 2, 0});
84  }
85  byte[] encValue = blockEncryptionAlgorithm.getName().getBytes(Util.UTF8_STRING_ENCODING);
86  byte[] epu = Base64Util.unsignedToBytes(new int[]{0, 0, 0, 0});
87  byte[] epv = Base64Util.unsignedToBytes(new int[]{0, 0, 0, 0});
88  byte[] label = "Integrity".getBytes(Util.UTF8_STRING_ENCODING);
89  byte[] round1Input = ArrayUtils.addAll(round1, cmk);
90  round1Input = ArrayUtils.addAll(round1Input, outputBitSize);
91  round1Input = ArrayUtils.addAll(round1Input, encValue);
92  round1Input = ArrayUtils.addAll(round1Input, epu);
93  round1Input = ArrayUtils.addAll(round1Input, epv);
94  round1Input = ArrayUtils.addAll(round1Input, label);
95 
96  MessageDigest mda = MessageDigest.getInstance(blockEncryptionAlgorithm.getMessageDiggestAlgorithm(), "BC");
97  byte[] cik = mda.digest(round1Input);
98 
99  return cik;
100  }

このクラス詳解は次のファイルから抽出されました: