/** * @param type * @return */ protected static NegotiateContextResponse createContext ( int type ) { switch ( type ) { case EncryptionNegotiateContext.NEGO_CTX_ENC_TYPE: return new EncryptionNegotiateContext(); case PreauthIntegrityNegotiateContext.NEGO_CTX_PREAUTH_TYPE: return new PreauthIntegrityNegotiateContext(); } return null; }
private static boolean checkEncryptionContext ( Smb2NegotiateRequest req, EncryptionNegotiateContext ec ) { if ( ec.getCiphers() == null || ec.getCiphers().length != 1 ) { log.error("Server returned no cipher selection"); return false; } EncryptionNegotiateContext rec = null; for ( NegotiateContextRequest rnc : req.getNegotiateContexts() ) { if ( rnc instanceof EncryptionNegotiateContext ) { rec = (EncryptionNegotiateContext) rnc; } } if ( rec == null ) { return false; } boolean valid = false; for ( int cipher : rec.getCiphers() ) { if ( cipher == ec.getCiphers()[ 0 ] ) { valid = true; } } if ( !valid ) { log.error("Server returned invalid cipher selection"); return false; } return true; }
/** * @param type * @return */ protected static NegotiateContextResponse createContext ( int type ) { switch ( type ) { case EncryptionNegotiateContext.NEGO_CTX_ENC_TYPE: return new EncryptionNegotiateContext(); case PreauthIntegrityNegotiateContext.NEGO_CTX_PREAUTH_TYPE: return new PreauthIntegrityNegotiateContext(); } return null; }
private static boolean checkEncryptionContext ( Smb2NegotiateRequest req, EncryptionNegotiateContext ec ) { if ( ec.getCiphers() == null || ec.getCiphers().length != 1 ) { log.error("Server returned no cipher selection"); return false; } EncryptionNegotiateContext rec = null; for ( NegotiateContextRequest rnc : req.getNegotiateContexts() ) { if ( rnc instanceof EncryptionNegotiateContext ) { rec = (EncryptionNegotiateContext) rnc; } } if ( rec == null ) { return false; } boolean valid = false; for ( int cipher : rec.getCiphers() ) { if ( cipher == ec.getCiphers()[ 0 ] ) { valid = true; } } if ( !valid ) { log.error("Server returned invalid cipher selection"); return false; } return true; }
negoContexts.add(new EncryptionNegotiateContext(config, new int[] { EncryptionNegotiateContext.CIPHER_AES128_GCM, EncryptionNegotiateContext.CIPHER_AES128_CCM }));
return false; this.selectedCipher = enc.getCiphers()[ 0 ]; this.supportsEncryption = true;
negoContexts.add(new EncryptionNegotiateContext(config, new int[] { EncryptionNegotiateContext.CIPHER_AES128_GCM, EncryptionNegotiateContext.CIPHER_AES128_CCM }));
return false; this.selectedCipher = enc.getCiphers()[ 0 ]; this.supportsEncryption = true;