NTSTATUS common_decrypt_buffer(struct smb_trans_enc_state *es, char *buf) { if (!common_encryption_on(es)) { /* Not decrypting. */ return NT_STATUS_OK; } return common_gensec_decrypt_buffer(es->gensec_security, buf); }
NTSTATUS common_encrypt_buffer(struct smb_trans_enc_state *es, char *buffer, char **buf_out) { if (!common_encryption_on(es)) { /* Not encrypting. */ *buf_out = buffer; return NT_STATUS_OK; } return common_gensec_encrypt_buffer(es->gensec_security, es->enc_ctx_num, buffer, buf_out); }
void common_free_enc_buffer(struct smb_trans_enc_state *es, char *buf) { uint16_t enc_ctx_num; if (!common_encryption_on(es)) { return; } if (!NT_STATUS_IS_OK(get_enc_ctx_num((const uint8_t *)buf, &enc_ctx_num))) { return; } SAFE_FREE(buf); }
NTSTATUS common_decrypt_buffer(struct smb_trans_enc_state *es, char *buf) { if (!common_encryption_on(es)) { /* Not decrypting. */ return NT_STATUS_OK; } switch (es->smb_enc_type) { case SMB_TRANS_ENC_NTLM: return common_gensec_decrypt_buffer(es->s.gensec_security, buf); #if defined(HAVE_GSSAPI) && defined(HAVE_KRB5) case SMB_TRANS_ENC_GSS: return common_gss_decrypt_buffer(es->s.gss_state, buf); #endif default: return NT_STATUS_NOT_SUPPORTED; } }