1
1
/*
2
- * Copyright (c) 2005, 2010 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2005, 2022 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -61,6 +61,7 @@ public static void main(String[] args) throws Exception {
61
61
byte [] clientRandom = null ;
62
62
byte [] serverRandom = null ;
63
63
String cipherAlgorithm = null ;
64
+ String hashAlgorithm = null ; // TLS1.2+ only
64
65
int keyLength = 0 ;
65
66
int expandedKeyLength = 0 ;
66
67
int ivLength = 0 ;
@@ -94,6 +95,8 @@ public static void main(String[] args) throws Exception {
94
95
serverRandom = parse (data );
95
96
} else if (line .startsWith ("km-cipalg:" )) {
96
97
cipherAlgorithm = data ;
98
+ } else if (line .startsWith ("km-hashalg:" )) {
99
+ hashAlgorithm = data ;
97
100
} else if (line .startsWith ("km-keylen:" )) {
98
101
keyLength = Integer .parseInt (data );
99
102
} else if (line .startsWith ("km-explen:" )) {
@@ -119,14 +122,36 @@ public static void main(String[] args) throws Exception {
119
122
n ++;
120
123
121
124
KeyGenerator kg =
122
- KeyGenerator .getInstance ("SunTlsKeyMaterial" , provider );
125
+ KeyGenerator .getInstance (minor == 3 ?
126
+ "SunTls12KeyMaterial" :
127
+ "SunTlsKeyMaterial" , provider );
123
128
SecretKey masterKey =
124
129
new SecretKeySpec (master , "TlsMasterSecret" );
130
+ int prfHashLength , prfBlockSize ;
131
+
132
+ if (hashAlgorithm != null ) {
133
+ switch (hashAlgorithm ) {
134
+ case "SHA-256" :
135
+ prfHashLength = 32 ;
136
+ prfBlockSize = 64 ;
137
+ break ;
138
+ case "SHA-384" :
139
+ prfHashLength = 48 ;
140
+ prfBlockSize = 128 ;
141
+ break ;
142
+ default :
143
+ throw new RuntimeException ("Unexpected hashalg: " +
144
+ hashAlgorithm );
145
+ }
146
+ } else {
147
+ prfHashLength = -1 ;
148
+ prfBlockSize = -1 ;
149
+ }
125
150
TlsKeyMaterialParameterSpec spec =
126
151
new TlsKeyMaterialParameterSpec (masterKey , major , minor ,
127
152
clientRandom , serverRandom , cipherAlgorithm ,
128
153
keyLength , expandedKeyLength , ivLength , macLength ,
129
- null , - 1 , - 1 );
154
+ hashAlgorithm , prfHashLength , prfBlockSize );
130
155
131
156
kg .init (spec );
132
157
TlsKeyMaterialSpec result =
3 commit comments
openjdk-notifier[bot] commentedon Oct 13, 2022
Review
Issues
GoeLin commentedon Apr 16, 2023
/backport jdk17u-dev
openjdk[bot] commentedon Apr 16, 2023
@GoeLin the backport was successfully created on the branch GoeLin-backport-94caecbe in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:
➡️ Create pull request
The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:
If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev: