More TLS for TPM efforts

This commit is contained in:
emanuel 2022-04-19 15:04:29 +01:00
parent 5e1f612c03
commit 1563f488cf
2 changed files with 24 additions and 8 deletions

View File

@ -225,7 +225,7 @@ static int transport_indication(facilities_t *facilities, void* responder, void*
break; break;
case 7011: case 7011:
if (facilities->tolling.active) { if (facilities->tolling.enabled) {
tpm_recv(facilities, its_msg, security_socket, neighbour_cert, NULL, 0); tpm_recv(facilities, its_msg, security_socket, neighbour_cert, NULL, 0);
} }
break; break;
@ -274,6 +274,8 @@ static int transport_indication(facilities_t *facilities, void* responder, void*
goto cleanup; goto cleanup;
} }
syslog_err("initializing? %s", srep->data->choice.tlsRecv.initializing ? "yes" : "no");
// Forward to [transport] // Forward to [transport]
if (srep->data->choice.tlsRecv.initializing) { if (srep->data->choice.tlsRecv.initializing) {
tr = calloc(1, sizeof(TransportRequest_t)); tr = calloc(1, sizeof(TransportRequest_t));
@ -309,11 +311,14 @@ static int transport_indication(facilities_t *facilities, void* responder, void*
it2s_tender_queue_send(facilities->tx_queue, buf, enc.encoded+1, ITSS_TRANSPORT, id, "TR.packet.tcp"); it2s_tender_queue_send(facilities->tx_queue, buf, enc.encoded+1, ITSS_TRANSPORT, id, "TR.packet.tcp");
} else { } else {
if (facilities->tolling.active) {
dec = uper_decode_complete(NULL, &asn_DEF_TPM, (void**) &its_msg, tpi->choice.tcp.data.buf, tpi->choice.tcp.data.size); syslog_err("tolling enabled? %s", facilities->tolling.active ? "yes" : "no");
if (facilities->tolling.enabled) {
dec = uper_decode_complete(NULL, &asn_DEF_TPM, (void**) &its_msg, srep->data->choice.tlsRecv.data.buf, srep->data->choice.tlsRecv.data.size);
syslog_err("tpm decode: %d", dec.code);
if (dec.code) { if (dec.code) {
syslog_debug("[facilities]<- invalid %s received", its_msg_descriptor->name); syslog_debug("[facilities]<- invalid TPM received");
rv = 1; rv = 1;
goto cleanup; goto cleanup;
} }

View File

@ -168,6 +168,7 @@ int tpm_pay(void* fc, tolling_info_s* info, void* security_socket, uint8_t* neig
bpr->gn.destinationAddress.size = 6; bpr->gn.destinationAddress.size = 6;
bpr->gn.trafficClass = 2; bpr->gn.trafficClass = 2;
bpr->gn.packetTransportType = PacketTransportType_shb; bpr->gn.packetTransportType = PacketTransportType_shb;
break;
case TOLLING_PROTOCOL_TLS: case TOLLING_PROTOCOL_TLS:
sreq = calloc(1, sizeof(SecurityRequest_t)); sreq = calloc(1, sizeof(SecurityRequest_t));
sreq->present = SecurityRequest_PR_tlsSend; sreq->present = SecurityRequest_PR_tlsSend;
@ -277,13 +278,23 @@ static void rsu_handle_recv(facilities_t* facilities, TPM_t* tpm_rx, void* secur
TollRequest_t* req = &tpm_rx->tpm.tollingFlow.choice.request; TollRequest_t* req = &tpm_rx->tpm.tollingFlow.choice.request;
tolling_s* tolling = &facilities->tolling; tolling_s* tolling = &facilities->tolling;
syslog_info("[facilities] [tolling] received toll payment > client: %ld (certificate id: %02x%02x%02x) | nonce: %ld", switch (tolling->protocol) {
case TOLLING_PROTOCOL_SIMPLE:
syslog_info("[facilities] [tolling] received toll payment > client: %ld (certificate id: %02x%02x%02x) | nonce: %ld",
req->clientId, req->clientId,
neighbour ? neighbour[5] : 0, neighbour ? neighbour[5] : 0,
neighbour ? neighbour[6] : 0, neighbour ? neighbour[6] : 0,
neighbour ? neighbour[7] : 0, neighbour ? neighbour[7] : 0,
req->transactionNonce req->transactionNonce
); );
break;
case TOLLING_PROTOCOL_TLS:
syslog_info("[facilities] [tolling] received toll payment > client: %ld | nonce: %ld",
req->clientId,
req->transactionNonce
);
break;
}
const size_t buf_len = 2048; const size_t buf_len = 2048;
uint8_t buf[buf_len]; uint8_t buf[buf_len];
@ -433,11 +444,12 @@ static void rsu_handle_recv(facilities_t* facilities, TPM_t* tpm_rx, void* secur
uint64_t id = 0; uint64_t id = 0;
tr = calloc(1, sizeof(TransportRequest_t));
tr->present = TransportRequest_PR_packet;
// [transport] request (TR) // [transport] request (TR)
switch (tolling->protocol) { switch (tolling->protocol) {
case TOLLING_PROTOCOL_SIMPLE: case TOLLING_PROTOCOL_SIMPLE:
tr = calloc(1, sizeof(TransportRequest_t));
tr->present = TransportRequest_PR_packet;
tr->choice.packet.present = TransportPacketRequest_PR_btp; tr->choice.packet.present = TransportPacketRequest_PR_btp;
BTPPacketRequest_t* bpr = &tr->choice.packet.choice.btp; BTPPacketRequest_t* bpr = &tr->choice.packet.choice.btp;
@ -488,7 +500,6 @@ static void rsu_handle_recv(facilities_t* facilities, TPM_t* tpm_rx, void* secur
} }
syslog_debug("[facilities] [tolling]<- SecurityReply.tlsSend <-[security]"); syslog_debug("[facilities] [tolling]<- SecurityReply.tlsSend <-[security]");
SecurityReply_t* srep = NULL;
asn_dec_rval_t dec = oer_decode(NULL, &asn_DEF_SecurityReply, (void**) &srep, buf, buf_len); asn_dec_rval_t dec = oer_decode(NULL, &asn_DEF_SecurityReply, (void**) &srep, buf, buf_len);
if (dec.code || if (dec.code ||