# Received Key Processor Application - User Guide

## Table of Contents

1. [Introduction](#1-introduction)
2. [System Requirements](#2-system-requirements)
   1. [Hardware](#21-hardware)
   2. [Software](#22-software)
   3. [Permissions](#23-permissions)
3. [Installation and Setup](#3-installation-and-setup)
   1. [Obtain the Application](#31-obtain-the-application)
   2. [Verify Files](#32-verify-files)
   3. [Launch the Application](#33-launch-the-application)
   4. [Initial Configuration](#34-initial-configuration)
4. [Main Features Overview](#4-main-features-overview)
   1. [Serial Port Communication](#41-serial-port-communication)
   2. [XML Processing](#42-xml-processing)
   3. [Database Storage](#43-database-storage)
   4. [Mission Planning](#44-mission-planning)
   5. [Duplicate Prevention](#45-duplicate-prevention)
   6. [Data Export](#46-data-export)
5. [FDU (Field Data Unit) Viewer](#5-fdu-field-data-unit-viewer)
   1. [Opening the FDU Viewer](#51-opening-the-fdu-viewer)
   2. [Viewing FDU Data](#52-viewing-fdu-data)
   3. [Understanding Tag Formats](#53-understanding-tag-formats)
   4. [Viewing Detection Results](#54-viewing-detection-results)
6. [MIDS JTRS Tag Editing](#6-mids-jtrs-tag-editing)
   1. [What Is a MIDS JTRS Tag](#61-what-is-a-mids-jtrs-tag)
   2. [Opening the Tag Editor](#62-opening-the-tag-editor)
   3. [Viewing Tag Information](#63-viewing-tag-information)
   4. [Editing a Tag](#64-editing-a-tag)
   5. [Saving Changes](#65-saving-changes)
   6. [Cancelling Changes](#66-cancelling-changes)
7. [ECU KEK ID Calculation](#7-ecu-kek-id-calculation)
   1. [What Is ECU KEK ID](#71-what-is-ecu-kek-id)
   2. [Calculating ECU KEK ID](#72-calculating-ecu-kek-id)
   3. [When to Use This Feature](#73-when-to-use-this-feature)
8. [Binary Tag Detection](#8-binary-tag-detection)
   1. [How Detection Works](#81-how-detection-works)
   2. [Viewing Detection Results](#82-viewing-detection-results)
   3. [Low Confidence Scores](#83-low-confidence-scores)
9. [Database Management](#9-database-management)
   1. [Opening the Database Viewer](#91-opening-the-database-viewer)
   2. [Database Structure](#92-database-structure)
   3. [Viewing Data](#93-viewing-data)
   4. [Searching and Filtering](#94-searching-and-filtering)
   5. [Send to SKL](#95-send-to-skl)
   6. [Fill Key to ECU](#96-fill-key-to-ecu)
   7. [Database Location](#97-database-location)
   8. [Backup and Restore](#98-backup-and-restore)
10. [WII Management](#10-wii-management)
    1. [Overview](#101-overview)
    2. [Adding a New WII](#102-adding-a-new-wii)
    3. [Editing a WII](#103-editing-a-wii)
    4. [Deleting WIIs](#104-deleting-wiis)
    5. [Saving Changes](#105-saving-changes)
11. [Mission Planner](#11-mission-planner)
    1. [Overview](#111-overview)
    2. [Creating a Mission Plan](#112-creating-a-mission-plan)
    3. [Configuring Mission Groups](#113-configuring-mission-groups)
    4. [WII Selection](#114-wii-selection)
    5. [Saving a Mission Plan](#115-saving-a-mission-plan)
    6. [Editing an Existing Mission Plan](#116-editing-an-existing-mission-plan)
    7. [Exporting to CD](#117-exporting-to-cd)
12. [Troubleshooting Common Issues](#12-troubleshooting-common-issues)
    1. [Application Won't Start](#121-application-wont-start)
    2. [EKMS2.exe Not Found Error](#122-ekms2exe-not-found-error)
    3. [File Import Fails](#123-file-import-fails)
    4. [Database Access Errors](#124-database-access-errors)
    5. [Serial Port Communication Issues](#125-serial-port-communication-issues)
    6. [MIDS JTRS Tag Validation Errors](#126-mids-jtrs-tag-validation-errors)
    7. [Performance Issues](#127-performance-issues)
    8. [Getting Help](#128-getting-help)
13. [Security Considerations](#13-security-considerations)
    1. [Data Protection](#131-data-protection)
    2. [Best Practices](#132-best-practices)
14. [Quick Reference](#14-quick-reference)
    1. [Keyboard Shortcuts](#141-keyboard-shortcuts)
    2. [Supported File Formats](#142-supported-file-formats)
    3. [Version Information](#143-version-information)

---

## 1. Introduction

The Received Key Processor Application (RKPA) is a desktop application designed for military and government users who need to process, manage, and analyze cryptographic key data. This application provides a comprehensive suite of tools for:

- **Processing Key Files**: Convert and import 8727 binary files
- **Viewing FDUs**: Examine Field Data Units containing key information
- **Editing MIDS JTRS Tags**: Modify and validate MIDS (Joint Tactical Radio System) tags
- **Managing Databases**: Organize and store cryptographic key information
- **Detecting Tag Formats**: Automatically identify different tag types

This application is built for Windows and uses a secure, layered architecture to protect sensitive cryptographic data.

---

## 2. System Requirements

### 2.1 Hardware

- **Processor**: Intel Core i5 or equivalent (recommended)
- **RAM**: 8 GB minimum, 16 GB recommended
- **Disk Space**: 500 MB for application, additional space for database storage
- **Display**: 1920x1080 resolution or higher

### 2.2 Software

- **Operating System**: Windows 10 or Windows 11
- **Runtime**: .NET 8.0 Windows Desktop Runtime
- **External Tool**: EKMS2.exe (must be in application directory)

### 2.3 Permissions

- Write access to local application data directory (for database storage)
- Write access to system temporary directory (for secure file processing)
- Read/write access to serial ports (if using COM port communication)

---

## 3. Installation and Setup

### 3.1 Obtain the Application

1. Download the application package from your authorized source
2. Extract all files to a folder on your computer (e.g., `C:\Program Files\RKPA\`)

### 3.2 Verify Files

Ensure the following files are present in the application directory:

- `EKMS2.exe` - Required for processing 8727 binary files
- `ReceivedKeyProcessorApp.exe` - Main application executable
- Supporting DLL files

### 3.3 Launch the Application

1. Navigate to the application folder
2. Double-click `ReceivedKeyProcessorApp.exe`
3. The application will launch and create the database automatically on first run

**Note**: The database is stored in `%LOCALAPPDATA%\ReceivedKeyProcessorApp\keys.db`

### 3.4 Initial Configuration

The application will automatically configure itself on first launch. Default settings include:

- Database location: User's local AppData folder
- Log files: Application directory
- Temporary files: System temp directory with secure cleanup

---

## 4. Main Features Overview

The application provides several key features accessible through the main interface:

### 4.1 Serial Port Communication

Receive cryptographic key data directly from radio equipment via COM port connection. This feature allows for real-time key transfer from field devices.

### 4.2 XML Processing

Parse and validate Tier3 XML payloads containing key information. The application validates XML structure and imports data into the database.

### 4.3 Database Storage

All processed key data is stored securely in a SQLite database with the following hierarchy:

- **Keys** - Top-level key records
- **Short Titles** - Key identifiers with material type information
- **Editions** - Key versions with classification and use information
- **Segments** - Actual cryptographic key data

### 4.4 Mission Planning

Create and manage mission plans that assign specific keys to missions. Includes validation to ensure keys are properly configured. See [Section 11: Mission Planner](#11-mission-planner) for detailed instructions.

### 4.5 Duplicate Prevention

The application uses hash-based detection to prevent duplicate key data from being imported, ensuring data integrity.

### 4.6 Data Export

Export processed data in various formats for use with other systems or for archival purposes.

---

## 5. FDU (Field Data Unit) Viewer

The FDU Viewer allows you to examine Field Data Units containing cryptographic key information.

### 5.1 Opening the FDU Viewer

1. From the main menu, navigate to **FDU Viewer**
2. The FDU Viewer screen will appear

### 5.2 Viewing FDU Data

The FDU Viewer displays:

- **Raw Data**: Hexadecimal representation of the FDU bytes
- **Decoded Information**: Human-readable interpretation of the data
- **Tag Detection**: Automatic detection of tag format with confidence score

### 5.3 Understanding Tag Formats

The application can detect several tag formats:

| Format | Description |
|--------|-------------|
| JMPS | Jump Tag |
| TR | Tactical Radio with DS-100-1 |
| MIDS JTRS | MIDS format |
| IFF | IFF format |
| DS-100-1 | Transfer Key Encryption Key |
| Composite | JMPS + DS-100-1 combined |

### 5.4 Viewing Detection Results

When an FDU is loaded, the application displays:

- **Detected Format**: The most likely tag format
- **Confidence Score**: Percentage indicating how well the data matches the format
- **Score Breakdown**: Detailed explanation of why the format was detected
- **Warnings**: Any validation issues found

---

## 6. MIDS JTRS Tag Editing

The MIDS JTRS (Joint Tactical Radio System) Tag Editor allows you to decode, view, edit, and encode MIDS JTRS tags.

### 6.1 What Is a MIDS JTRS Tag

A MIDS JTRS tag is a data structure containing key metadata and configuration information used by tactical radio systems. The tag includes information such as:

- Key function and classification
- Waveform information
- Start time and crypto period
- Update rules and methods
- Validation codes

### 6.2 Opening the Tag Editor

1. Navigate to **FDU Viewer**
2. Load an FDU containing MIDS JTRS tag data
3. The MIDS JTRS tag will be automatically detected and displayed

### 6.3 Viewing Tag Information

The tag is displayed in two sections:

**Control Tag** - Contains key metadata including classification, compartment, waveform affiliation, start time, crypto period, and update settings.

**Extension Tag** - Contains additional key information including short title, edition, segment number, and ECU KEK ID.

### 6.4 Editing a Tag

1. Click the **Edit** button in the top-right corner of the MIDS JTRS Tag section
2. The button text changes to **Save** and all editable fields become active
3. Make your changes:
   - **Text Fields**: Click and type the new value
   - **Dropdown Fields**: Select from the available options (Classification, Compartment, Key Function, Waveform Affiliation, etc.)

### 6.5 Saving Changes

1. Click the **Save** button
2. The application automatically validates all field values and recalculates validation codes
3. A success message appears

### 6.6 Cancelling Changes

1. Click the **Cancel** button
2. All fields revert to their original values
3. Edit mode exits

---

## 7. ECU KEK ID Calculation

The ECU KEK ID (Electronic Control Unit Key Encryption Key Identifier) uniquely identifies the ECU KEK used to encrypt a key. This feature allows you to calculate and validate ECU KEK IDs.

### 7.1 What Is ECU KEK ID

The ECU KEK ID is calculated from the Short Title, Edition, and Segment Number of a key. It helps verify that the correct encryption key is associated with the key data.

### 7.2 Calculating ECU KEK ID

1. Navigate to **FDU Viewer** and load an FDU containing a MIDS JTRS tag
2. In the Extension Tag section, locate the **ECU KEK ID** field
3. Click the **Calculate ECU KEK ID** button next to the field
4. A dialog appears showing the input values and the calculated result
5. Click **Close** to dismiss the dialog

The calculated value is for viewing only and does not update the tag data.

### 7.3 When to Use This Feature

Use this feature when you need to:

- Verify that an existing ECU KEK ID is correct
- Validate that the ECU KEK ID matches the expected value for a given Short Title, Edition, and Segment

---

## 8. Binary Tag Detection

The application automatically detects and identifies different tag formats in FDU data. This helps you understand what type of key data you are working with.

### 8.1 How Detection Works

When you load an FDU, the application:

1. **Analyzes the Data**: Examines the structure and patterns
2. **Tests Each Format**: Tries to match the data against known tag formats
3. **Calculates Scores**: Assigns a confidence score to each format
4. **Selects Best Match**: Displays the format with the highest score

### 8.2 Viewing Detection Results

1. Load an FDU in the FDU Viewer
2. Look at the **Tag Detection** section
3. You will see the detected format, confidence score, and any warnings

### 8.3 Low Confidence Scores

If the detected format has a low confidence score:

1. **Review the Warnings**: Check what validation issues were found
2. **Verify the Data**: Ensure you loaded the correct file
3. **Check File Format**: The file may not contain the expected tag format
4. **Consult Documentation**: Refer to format specifications for more details

---

## 9. Database Management

The application stores all processed key data in a SQLite database. You can view and manage this data through the Database Viewer.

### 9.1 Opening the Database Viewer

1. From the main menu, navigate to **Database**
2. The Database Viewer screen will appear

### 9.2 Database Structure

The database uses a hierarchical structure:

```
Keys (Top Level)
  └── Short Titles
      └── Editions
          └── Segments (Contains the actual key data)
```

### 9.3 Viewing Data

The Database Viewer provides three views:

**Hierarchical View** - Displays the data in a tree structure. Expand Keys to see Short Titles, Short Titles to see Editions, and Editions to see Segments.

**Table View** - Displays data in a tabular format. Use this view to see multiple records at once, sort by any column, and filter data.

**Details View** - Shows complete information for a selected record including all field values, classification, key use, and segment data.

### 9.4 Searching and Filtering

**Search**: Use the **Search** box at the top of the screen. Results are filtered as you type.

**Filter**: Click the **Filter** button, select criteria (Classification, Key Use, Date Range, Material Type), and click **Apply**.

### 9.5 Send to SKL

You can send cryptographic key segments directly to an SKL (Single Key Loader) device from the database hierarchical view.

**Access**: Database page → Expand hierarchical view → Right-click on segment(s) → "Send to SKL"

**What happens**:
1. An output window appears showing real-time progress
2. The application generates the key content and sends it to the SKL
3. The output window shows the result of the transmission

**Output Window Features**:
- **Copy All**: Copies all output text to clipboard
- **Cancel**: Cancels the in-progress send operation
- **Close**: Closes the output window

### 9.6 Fill Key to ECU

The Fill Key to ECU dialog generates MIDS JTRS fill content for Electronic Control Units.

**Access**: Database page → Expand hierarchical view → Right-click on segment → "Fill Key to ECU"

**Dialog Features**:
1. **Tag Types Selection**: Choose the tag type
2. **Template Selection**: Select from available tag templates
3. **Tag Fields**: View resolved field values
4. **Generated Output**: Shows the output after generation

**Action Buttons**:

| Button | Description |
|--------|-------------|
| **Generate** | Creates fill content from the selected template |
| **Save** | Saves generated output to a file |
| **Send to SKL** | Sends the content directly to an SKL device |
| **Cancel** | Closes the dialog |

### 9.7 Database Location

The database is stored at:

```
%LOCALAPPDATA%\ReceivedKeyProcessorApp\keys.db
```

Typical location on Windows 10/11: `C:\Users\[Username]\AppData\Local\ReceivedKeyProcessorApp\keys.db`

### 9.8 Backup and Restore

**Backup**:
1. Close the application
2. Navigate to the database location
3. Copy the `keys.db` file to a safe location

**Restore**:
1. Close the application
2. Backup the current `keys.db` file
3. Copy your backup `keys.db` file to the database location
4. Restart the application

---

## 10. WII Management

### 10.1 Overview

The WII (Waveform Instance Identifier) Management tab allows you to view, add, edit, and delete WII values used by the application. WII values identify waveform instance configurations and are referenced by mission plans.

**Access**: Database page → WII Management tab

The WII Management tab displays a table with two columns:

| Column | Description |
|--------|-------------|
| **Value** | The WII identifier |
| **Description** | Human-readable description of the WII |

When a new database is created, it is automatically seeded with **HHL16** (High-Level Link 16) as the default WII value.

### 10.2 Adding a New WII

1. Click the **Add** button (+) in the toolbar
2. A new row appears with placeholder values
3. Edit the **Value** and **Description** fields
4. Click **Save** to persist the new WII to the database

### 10.3 Editing a WII

1. Click on any cell in the WII table
2. Type the new value
3. Click **Save** to persist changes to the database

### 10.4 Deleting WIIs

1. Click a row to select it (hold **Ctrl** to select multiple rows)
2. Click the **Delete** button (X) in the toolbar, or press the **Delete** key
3. Selected rows are immediately removed from the table
4. Click **Save** to persist the deletions to the database

**Note**: Deletions are not persisted until you click **Save**. If you navigate away before saving, the deleted rows will reappear when you return.

### 10.5 Saving Changes

Click the **Save** button to persist all adds, edits, and deletions to the database. The status bar at the bottom of the table displays a confirmation message or any error that occurred.

---

## 11. Mission Planner

### 11.1 Overview

The Mission Planner allows you to create and manage cryptographic mission plans that assign specific keys to mission groups. Each mission group defines the keys and parameters needed for secure communications.

**Access**: Navigate to the **Mission Planner** page from the main menu.

The Mission Planner supports:
- Creating mission plans with multiple mission groups
- Automatic BTEK to WKEK key linking
- WII (Waveform Instance Identifier) selection per group
- Equipment profile selection (L3Harris, Collins/Raytheon, AN/PRC-161)
- Exporting mission plans to CD for field deployment

### 11.2 Creating a Mission Plan

1. Enter a **Mission Name** in the text field at the top of the page
2. Optionally enter a **Description**
3. Select an **Equipment Profile** from the dropdown (L3Harris, Collins/Raytheon, AN/PRC-161)
4. Click **Add Mission Group** to create a new mission group

### 11.3 Configuring Mission Groups

Each mission group requires the following fields:

| Field | Description |
|-------|-------------|
| **BTEK Short Title** | Black Traffic Encryption Key identifier |
| **BTEK Edition** | Specific edition of the BTEK |
| **WKEK/WBKEK Short Title** | Multifunction Key identifier (auto-linked from BTEK) |
| **WKEK/WBKEK Edition** | Specific edition of the WKEK |
| **WII** | Waveform Instance Identifier (exactly 9 characters) |
| **Mission CVLL** | Cryptographic Verification List Level (R001-R127) |
| **Encryption Type** | Encryption algorithm |
| **Start Date** | Mission effective start date (first group: 1st of current month; subsequent groups: month following previous group) |
| **End Date** | Mission effective end date (last day of start month) |

**Auto-linking**: When you select a BTEK with a "BL" variant, the system automatically finds and selects the matching "KL" variant WKEK and matching edition.

**KS0 fields**: When using Collins/Raytheon equipment, KS0 Short Title and Edition fields are also available.

### 11.4 WII Selection

The WII (Waveform Instance Identifier) field supports two input methods:

- **Dropdown**: Select from existing WII values managed in the WII Management tab
- **Manual entry**: Type a new 9-character WII value directly

The application remembers the last used WII and pre-selects it when creating new mission groups. WII values must be exactly 9 characters — a red validation warning appears if the length is incorrect.

### 11.5 Saving a Mission Plan

1. Fill in the Mission Name and all required mission group fields
2. Click the **Save** button
3. The mission plan is saved to the database
4. A confirmation message appears

**Note**: If a WII value you entered does not already exist in the database, it will be automatically created when you save the mission plan.

### 11.6 Editing an Existing Mission Plan

1. Select a saved mission plan from the **Mission Plan Name** dropdown
2. The mission plan's groups are loaded
3. Modify any field as needed
4. Click **Save** to update the mission plan

### 11.7 Exporting to CD

1. Select or create a mission plan
2. Click **Export to CD**
3. Select the target drive or folder
4. The system creates the folder structure with key files organized by key type (BTEK, WKEK, KS0) and a JSON manifest file

---

## 12. Troubleshooting Common Issues

### 12.1 Application Won't Start

**Symptom**: Application fails to launch or crashes immediately

**Possible Causes**:
- .NET 8.0 Runtime not installed
- Missing required files (EKMS2.exe, DLLs)
- Insufficient permissions

**Solutions**:
1. Verify .NET 8.0 Windows Desktop Runtime is installed
2. Check that EKMS2.exe is in the application directory
3. Run the application as Administrator
4. Check Windows Event Viewer for error details

### 12.2 EKMS2.exe Not Found Error

**Symptom**: Error message "EKMS2.exe not found"

**Solutions**:
1. Ensure EKMS2.exe is in the same folder as the application executable
2. Verify the file name is exactly "EKMS2.exe"
3. Check file permissions on EKMS2.exe
4. Reinstall or obtain the correct version of EKMS2.exe

### 12.3 File Import Fails

**Symptom**: Unable to import .8727 or .bin files

**Possible Causes**:
- Invalid file format
- Corrupted file
- EKMS2.exe processing failure
- Permission issues

**Solutions**:
1. Verify the file is in the correct format (.8727, .8287, .bin, .key)
2. Check file size (very small or very large files may be invalid)
3. Ensure EKMS2.exe can access the file
4. Check that you have write permissions to the temp directory

### 12.4 Database Access Errors

**Symptom**: Cannot access or save data to the database

**Possible Causes**:
- Database file locked
- Insufficient permissions
- Disk full
- Database corruption

**Solutions**:
1. Close all other instances of the application
2. Check disk space on the drive where %LOCALAPPDATA% is located
3. Run the application as Administrator
4. Restore from backup if database is corrupted
5. Delete the database file and let the application recreate it (you will lose all data)

### 12.5 Serial Port Communication Issues

**Symptom**: Unable to connect to COM port or receive data

**Possible Causes**:
- Wrong COM port selected
- Port already in use
- Incorrect baud rate
- Hardware not connected

**Solutions**:
1. Verify the correct COM port number in Device Manager
2. Close other applications that may be using the port
3. Check baud rate settings match the equipment
4. Ensure hardware is properly connected
5. Run as Administrator for port access

### 12.6 MIDS JTRS Tag Validation Errors

**Symptom**: Error when editing or saving MIDS JTRS tags

**Solutions**:
1. Review all field values are within valid ranges
2. Verify that Internal JTRS Key ID matches in both Control and Extension tags
3. Check that text fields do not exceed maximum lengths
4. Cancel edit and try again if errors persist

### 12.7 Performance Issues

**Symptom**: Application runs slowly or freezes

**Solutions**:
1. Close unnecessary applications
2. Process smaller batches of files
3. Restart the application periodically
4. Check for high CPU usage from other processes

### 12.8 Getting Help

If you continue to experience issues:

1. **Check Logs**: Review application logs in the application directory
2. **Review Documentation**: Consult this User Guide and technical documentation
3. **Contact Support**: Reach out to your system administrator or support team
4. **Report Bugs**: Provide detailed error messages and steps to reproduce

---

## 13. Security Considerations

### 13.1 Data Protection

This application processes sensitive cryptographic data. Follow these security practices:

1. **Secure Environment**: Run on secure, authorized computers only
2. **Access Control**: Limit access to authorized personnel
3. **Backup Security**: Encrypt backups and store securely
4. **Log Protection**: Protect log files as they may contain sensitive information
5. **Secure Deletion**: The application securely wipes temporary files

### 13.2 Best Practices

- Never share your database files with unauthorized personnel
- Regularly back up your database to secure storage
- Use strong passwords for any encryption features
- Keep the application and dependencies updated
- Report any security concerns immediately

---

## 14. Quick Reference

### 14.1 Keyboard Shortcuts

| Shortcut | Action |
|----------|--------|
| Ctrl+S | Save (when applicable) |
| Ctrl+F | Open search |
| Ctrl+Z | Undo (in edit mode) |
| Escape | Cancel current operation |
| F5 | Refresh view |

### 14.2 Supported File Formats

| Extension | Description |
|-----------|-------------|
| .8727 | Standard 8727 binary |
| .8287 | 8287 binary |
| .bin | Generic binary |
| .key | Key binary |
| .xml | XML format |
| .json | JSON format |

### 14.3 Version Information

Current Version: 1.0.107

For the latest version information and updates, contact your system administrator.

---

**End of User Guide**
