+/*
+ * Exports an IV from the CipherContext required to export the key
+ * state back from the unprivileged child to the privileged parent
+ * process.
+ */
+
+void
+packet_get_keyiv(int mode, u_char *iv, u_int len)
+{
+ CipherContext *cc;
+
+ if (mode == MODE_OUT)
+ cc = &active_state->send_context;
+ else
+ cc = &active_state->receive_context;
+
+ cipher_get_keyiv(cc, iv, len);
+}
+
+int
+packet_get_keycontext(int mode, u_char *dat)
+{
+ CipherContext *cc;
+
+ if (mode == MODE_OUT)
+ cc = &active_state->send_context;
+ else
+ cc = &active_state->receive_context;
+
+ return (cipher_get_keycontext(cc, dat));
+}
+
+void
+packet_set_keycontext(int mode, u_char *dat)
+{
+ CipherContext *cc;
+
+ if (mode == MODE_OUT)
+ cc = &active_state->send_context;
+ else
+ cc = &active_state->receive_context;
+
+ cipher_set_keycontext(cc, dat);
+}
+
+int
+packet_get_keyiv_len(int mode)
+{
+ CipherContext *cc;
+
+ if (mode == MODE_OUT)
+ cc = &active_state->send_context;
+ else
+ cc = &active_state->receive_context;
+
+ return (cipher_get_keyiv_len(cc));
+}
+
+void
+packet_set_iv(int mode, u_char *dat)
+{
+ CipherContext *cc;
+
+ if (mode == MODE_OUT)
+ cc = &active_state->send_context;
+ else
+ cc = &active_state->receive_context;
+
+ cipher_set_keyiv(cc, dat);
+}
+
+int
+packet_get_ssh1_cipher(void)
+{
+ return (cipher_get_number(active_state->receive_context.cipher));
+}
+
+void
+packet_get_state(int mode, u_int32_t *seqnr, u_int64_t *blocks, u_int32_t *packets,
+ u_int64_t *bytes)
+{
+ struct packet_state *state;
+
+ state = (mode == MODE_IN) ?
+ &active_state->p_read : &active_state->p_send;
+ if (seqnr)
+ *seqnr = state->seqnr;
+ if (blocks)
+ *blocks = state->blocks;
+ if (packets)
+ *packets = state->packets;
+ if (bytes)
+ *bytes = state->bytes;
+}
+
+void
+packet_set_state(int mode, u_int32_t seqnr, u_int64_t blocks, u_int32_t packets,
+ u_int64_t bytes)
+{
+ struct packet_state *state;
+
+ state = (mode == MODE_IN) ?
+ &active_state->p_read : &active_state->p_send;
+ state->seqnr = seqnr;
+ state->blocks = blocks;
+ state->packets = packets;
+ state->bytes = bytes;
+}
+