Skip to main content
  • Products
  • Evaluate our Software
  • Downloads
  • Free Utilities
  • Purchase
  • Support
  • About Us
  • Blog
  • Forum
  • Search
    • Contact Us
    • Forum
    • Knowledge Base
    • Web Shop
    • Newsletter
    • RSS
  •   Jobs
  •   Videos
  •   Blog
  •   Sustainability
  • emFile
  • Encryption
  • Technology
  • Add-ons
  • Tools

Encryption

Additional component that can be used to secure the data on the file system.

Contact us
Downloads
Documentation
SEGGER emFile
  1. 1.Overview
    1. 1.1.Key features
  2. 2.Editions
  3. 3.How to use encryption
    1. 3.1.Encryption on target side
    2. 3.2.Decryption on PC side
  4. 4.Performance

Overview

The Encryption add-on provides an easy way to secure the data of individual files or the data of a storage device as a whole. Encryption can be used with both available file systems (EFS and FAT) and with all supported storage device types such as NAND, NOR, and SD / MMC cards.

To use encryption, only minor changes to the application program are required. The rest of the application program works in the same way as without encryption.

Encryption and decryption is performed in the software at high speed. If hardware encryption is supported on the particular target, the file system can easily take advantage of this to increase the performance.

Key features

  • Can be used with both FAT and EFS file systems
  • All storage device types such as NAND, NOR, SD/MMC cards are supported
  • Minimal changes of the application are required
  • DES and AES with 128-bit and 256-bit key lengths supported
  • Supports encryption of entire media or of individual files
  • Comes with PC utility to decrypt/encrypt files

Editions

emFile Encryption is available in two different editions.

 EncryptionExtra Strong Encryption
DES
AES 128-bit
AES 256-bit

 

How to use encryption

Encryption on target side

Using file encryption is very simple from the perspective of the user. The following steps have to be performed to enable encryption in your application:

  • Enable file encryption in the emFile configuration by setting FS_SUPPORT_ENCRYPTION define to 1.
  • Call FS_CRYPT_Prepare() to initialize an encryption object. This operation has to be performed only once.
  • Open a file and call FS_SetEncryptionObject() to assign the encryption object to that file handle.

These are the only changes required to be performed in the application. Everything else is done by the Encryption add-on.

The following sample function opens a file and writes a text message to it. The file contents is encrypted using the DES encryption algorithm.

void FileEncryptionSample(void) {
  FS_FILE                * pFile;  
  const U8                 aKey[8] = {1, 2, 3, 4}; 
  FS_CRYPT_OBJ             CryptObj; 
  static FS_DES_CONTEXT    _Context;   
  static int               _IsInited; 
  
  //  
  // Create the encryption object. It contains all the necessary 
  // information for the encryption/decryption of data. This step 
  // has to be performed only once.  
  //  
  if (_IsInited == 0) {
    FS_CRYPT_Prepare(&CryptObj, 
                     &FS_CRYPT_ALGO_DES, 
                     &_Context, 
                     512, 
                     aKey);  
    _IsInited = 1;  
  }
  pFile = FS_FOpen("des.bin", "w");  
  if (pFile) {
    //
    // Assign the created encryption object to file handle.
    // 
    FS_SetEncryptionObject(pFile, &CryptObj);
    //
    // Write data to file using encryption.
    //  
    FS_Write(pFile, "This message has been encrypted using", 37);
    FS_Write(pFile, " SEGGER emFile Encryption add-on.\n", 33);
    FS_FClose(pFile);  
  }
}

Decryption on PC side

The file encrypted on the target system can be decrypted on a PC using the File Encrypter command line tool. The following screenshot shows the messages printed out by utily while decrypting the contents of the des.bin file. The decripted contents is stored to des.txt file. In this case the encryption algorithm used is DES as specified unsing the -a option. The File Encrypter utility shows information about the progress of the decrypting process. In case of an error, a message is displayed and the utility returns with a status of 1 and the file is not decrypted.

emfile encryption decryption

Performance

These performance measurements are in no way complete, but they give an approximation of the length of time required for common operations on various targets.

Target DeviceCPU speedStorage deviceWrite speedRead speed
NXP Kinetis K60120 MHz NAND flash interfaced via 8-bit bus using AES with an 128-bit key.522 Kbytes/sec553 Kbytes/sec
ST STM32F496 MHz SD card as storage medium using AES with an 128-bit key500 Kbytes/sec530 Kbytes/sec

Headquarters

SEGGER Microcontroller GmbH

Ecolab-Allee 5
40789 Monheim am Rhein, Germany
info@segger.com
Tel.: +49-2173-99312-0
Fax: +49-2173-99312-28

Locations

USA: SEGGER Microcontroller Systems LLC

Boston area
101 Suffolk Lane
Gardner, MA 01440, USA
us-east@segger.com
Tel.: +1-978-874-0299
Fax: +1-978-874-0599

Silicon Valley
Milpitas, CA 95035, USA
us-west@segger.com
Tel.: +1-408-767-4068

China: SEGGER Microcontroller China Co., Ltd.

Room 218, Block A, Dahongqiaoguoji
No. 133 Xiulian Road
Minhang District, Shanghai 201199, China
china@segger.com
Tel.: +86-133-619-907-60

ISO 9001 certified

ISO 9001

30+ years of experience

First-class embedded software tools since 1992
  • Imprint
  • Disclaimer
  • Privacy Policy
© 2025 SEGGER - All rights reserved.