request->packet->data_len = data_len;
secret = client->secret;
- if (secret) secretlen = talloc_array_length(client->secret) - 1;
+ if (secret) {
+ if (!packet_is_encrypted((fr_tacacs_packet_t const *) data)) {
+ REDEBUG("Expected to see encrypted packet, got unencrypted packet!");
+ return -1;
+ }
+ secretlen = talloc_array_length(client->secret) - 1;
+ }
/*
* Note that we don't set a limit on max_attributes here.
return -1;
}
- if (secret && !packet_is_encrypted(pkt)) {
- fr_strerror_const("Packet is clear-text but we expected it to be encrypted");
- return -1;
- }
-
/*
* Call the struct encoder to do the actual work.
*/
*
* If there's a secret, we alway decrypt the packets.
*/
- if (secret) {
+ if (secret && packet_is_encrypted(pkt)) {
size_t length;
if (!secret_len) {