private byte[] generateMIC() throws UserAuthException { byte[] msg = new PlainBuffer().putString(params.getTransport().getSessionID()) .putByte(Message.USERAUTH_REQUEST.toByte()) .putString(params.getUsername()) .putString(params.getNextServiceName()) .putString(getName()) .getCompactData(); try { return secContext.getMIC(msg, 0, msg.length, null); } catch (GSSException e) { throw new UserAuthException("Exception getting message integrity code", e); } }
public byte[] getMIC(byte[] message, int s, int l){ try{ MessageProp prop = new MessageProp(0, true); return context.getMIC(message, s, l, prop); } catch(GSSException ex){ return null; } }
public byte[] getMIC(byte[] message, int s, int l){ try{ MessageProp prop = new MessageProp(0, true); return context.getMIC(message, s, l, prop); } catch(GSSException ex){ return null; } }
@Override public byte[] getMIC(byte[] message, int offset, int length) { try { return _context.getMIC(message, offset, length, new MessageProp(0, true)); } catch(GSSException ex) { return null; } }
public byte[] getMIC(byte[] message, int s, int l){ try{ MessageProp prop = new MessageProp(0, true); return context.getMIC(message, s, l, prop); } catch(GSSException ex){ return null; } }
public byte[] getMIC(byte[] message, int s, int l){ try{ MessageProp prop = new MessageProp(0, true); return context.getMIC(message, s, l, prop); } catch(GSSException ex){ return null; } }
public byte[] getMIC(byte[] message, int s, int l){ try{ MessageProp prop = new MessageProp(0, true); return context.getMIC(message, s, l, prop); } catch(GSSException ex){ return null; } }
public byte[] getMIC(byte[] message, int s, int l){ try{ MessageProp prop = new MessageProp(0, true); return context.getMIC(message, s, l, prop); } catch(GSSException ex){ return null; } }
public byte[] getMIC(byte[] message, int s, int l) { try { MessageProp prop = new MessageProp(0, false); return context.getMIC(message, s, l, prop); } catch (GSSException ex) { logger.error(ex.getMessage(), ex); return null; } }
/** * {@inheritDoc} * * @throws CIFSException * * @see jcifs.smb.SSPContext#calculateMIC(byte[]) */ @Override public byte[] calculateMIC ( byte[] data ) throws CIFSException { try { return this.gssContext.getMIC(data, 0, data.length, new MessageProp(false)); } catch ( GSSException e ) { throw new CIFSException("Failed to calculate MIC", e); } }
/** * {@inheritDoc} * * @throws CIFSException * * @see jcifs.smb.SSPContext#calculateMIC(byte[]) */ @Override public byte[] calculateMIC ( byte[] data ) throws CIFSException { try { return this.gssContext.getMIC(data, 0, data.length, new MessageProp(false)); } catch ( GSSException e ) { throw new CIFSException("Failed to calculate MIC", e); } }
/** * Generate a message integrity check for a given received message. * @param context GSSContext for which a connection has been established to the remote peer * @param prop the MessageProp used for exchanging messages * @param message the bytes of the received message * @return the bytes of the message integrity check (like a checksum) that is * sent to a peer for verifying that the message was received correctly */ @Function public static byte[] generateMIC(GSSContext context, MessageProp prop, byte[] message) { try { // Ensure the default Quality-of-Protection is applied. prop.setQOP(0); byte[] initialToken = context.getMIC(message, 0, message.length, prop); return getTokenWithLengthPrefix(initialToken); } catch (GSSException ex) { throw new RuntimeException("Exception generating MIC for message", ex); } }
protected void doWith(GSSContext context, Transport.Connection conn) throws Exception { //if (context.getMutualAuthState()) { // System.out.println("Mutual authentication took place!"); //} MessageProp prop = new MessageProp(0, false); byte[] token = conn.recvToken(); byte[] bytes = context.unwrap(token, 0, token.length, prop); //String str = new String(bytes, StandardCharsets.UTF_8); // System.out.println("Received data \"" // + str + "\" of length " + str.length()); //System.out.println("Confidentiality applied: " // + prop.getPrivacy()); prop.setQOP(0); token = context.getMIC(bytes, 0, bytes.length, prop); //System.out.println("Will send MIC token of size " //+ token.length); conn.sendToken(token); }
private byte[] generateMIC() throws UserAuthException { byte[] msg = new PlainBuffer().putString(params.getTransport().getSessionID()) .putByte(Message.USERAUTH_REQUEST.toByte()) .putString(params.getUsername()) .putString(params.getNextServiceName()) .putString(getName()) .getCompactData(); try { return secContext.getMIC(msg, 0, msg.length, null); } catch (GSSException e) { throw new UserAuthException("Exception getting message integrity code", e); } }
private void sendMic(ClientSession session, String service) throws IOException, GSSException { state = ProtocolState.MIC_SENT; // Produce MIC Buffer micBuffer = new ByteArrayBuffer(); micBuffer.putBytes(session.getSessionId()); micBuffer.putByte(SshConstants.SSH_MSG_USERAUTH_REQUEST); micBuffer.putString(session.getUsername()); micBuffer.putString(service); micBuffer.putString(getName()); byte[] micBytes = micBuffer.getCompactData(); byte[] mic = context.getMIC(micBytes, 0, micBytes.length, new MessageProp(0, true)); Buffer buffer = session .createBuffer(SshConstants.SSH_MSG_USERAUTH_GSSAPI_MIC); buffer.putBytes(mic); session.writePacket(buffer); }