public byte[] generateMwk(){
  KeyGenerator keyGen=null;
  try {
    keyGen=KeyGenerator.getInstance("DES");
  }
 catch (  NoSuchAlgorithmException e) {
    Debug.logError(e,module);
  }
  SecretKey des1=keyGen.generateKey();
  SecretKey des2=keyGen.generateKey();
  if (des1 != null && des2 != null) {
    byte[] desByte1=des1.getEncoded();
    byte[] desByte2=des2.getEncoded();
    byte[] desByte3=des1.getEncoded();
    try {
      if (DESKeySpec.isWeak(des1.getEncoded(),0) || DESKeySpec.isWeak(des2.getEncoded(),0)) {
        return generateMwk();
      }
    }
 catch (    Exception e) {
      Debug.logError(e,module);
    }
    byte[] des3=copyBytes(desByte1,copyBytes(desByte2,desByte3,0),0);
    return generateMwk(des3);
  }
 else {
    Debug.logInfo("Null DES keys returned",module);
  }
  return null;
}

public byte [ ] generateMwk ( ) { KeyGenerator keyGen = null ; try { keyGen = KeyGenerator . getInstance ( "DES" ) ; } catch ( NoSuchAlgorithmException e ) { Debug . logError ( e , module ) ; } SecretKey des1 = keyGen . generateKey ( ) ; SecretKey des2 = keyGen . generateKey ( ) ; if ( des1 != null && des2 != null ) { byte [ ] desByte1 = des1 . getEncoded ( ) ; byte [ ] desByte2 = des2 . getEncoded ( ) ; byte [ ] desByte3 = des1 . getEncoded ( ) ; try { if ( DESKeySpec . isWeak ( des1 . getEncoded ( ) , 0 ) || DESKeySpec . isWeak ( des2 . getEncoded ( ) , 0 ) ) { return generateMwk ( ) ; } } catch ( Exception e ) { Debug . logError ( e , module ) ; } byte [ ] des3 = copyBytes ( desByte1 , copyBytes ( desByte2 , desByte3 , 0 ) , 0 ) ; return generateMwk ( des3 ) ; } else { Debug . logInfo ( "Null DES keys returned" , module ) ; } return null ; }
generate a new mwk
