You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by di...@apache.org on 2005/03/23 05:46:29 UTC
cvs commit: ws-fx/wss4j/src/org/apache/ws/security/conversation/dkAlgo P_SHA1.java
dims 2005/03/22 20:46:29
Modified: wss4j/src/org/apache/ws/security/conversation/dkAlgo
P_SHA1.java
Log:
fix the bug in using the P_SHA-1 key
Revision Changes Path
1.4 +9 -5 ws-fx/wss4j/src/org/apache/ws/security/conversation/dkAlgo/P_SHA1.java
Index: P_SHA1.java
===================================================================
RCS file: /home/cvs/ws-fx/wss4j/src/org/apache/ws/security/conversation/dkAlgo/P_SHA1.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- P_SHA1.java 9 Aug 2004 18:02:46 -0000 1.3
+++ P_SHA1.java 23 Mar 2005 04:46:29 -0000 1.4
@@ -40,11 +40,11 @@
* @version 1.0
*/
-import org.apache.ws.security.conversation.ConversationException;
-
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
+import org.apache.ws.security.conversation.ConversationException;
+
public class P_SHA1
implements DerivationAlgorithm {
@@ -55,9 +55,13 @@
long length) throws ConversationException {
try {
Mac mac = Mac.getInstance("HmacSHA1");
- byte[] key = new String(P_hash(secret, labelAndNonce.getBytes(), mac,
- (offset + (int) length))).substring(offset,
- (int) length).getBytes();
+
+ byte[] tempBytes = P_hash(secret, labelAndNonce.getBytes(), mac,(offset + (int) length));
+
+ byte[] key = new byte[(int)length];
+
+ for(int i = 0; i < key.length; i++)
+ key[i] = tempBytes[i+offset];
return key;
} catch (Exception ex) {