---
title: SecurityMessage
framework: accessorytransportextension
role: symbol
role_heading: Structure
path: accessorytransportextension/securitymessage
---

# SecurityMessage

A structure that carries key material for a secure channel between the system and an accessory.

## Declaration

```swift
struct SecurityMessage
```

## Mentioned in

Receiving iOS notifications on an accessory

## Overview

Overview Your AccessoryTransportSecurity extension provides instances of this type to initiate key exchange and receives them during messageReceived(_:completion:) to complete the exchange. Derive encryption secrets Export HPKE secrets once during key exchange when handling SecurityMessage.KeyType.encapsulatedKey. Store the exported secrets for both HostToAccessory and AccessoryToHost directions for all subsequent message encryption and decryption. important: On the accessory, use recipient.exportSecret(context:outputByteCount:) to derive secrets. The accessory creates an HPKE recipient; iPhone creates the sender.

## Topics

### Creating security messages

- [init(keyType:cipherSuite:version:key:supportedTransports:identifier:)](accessorytransportextension/securitymessage/init(keytype:ciphersuite:version:key:supportedtransports:identifier:).md)

### Accessing key material

- [key](accessorytransportextension/securitymessage/key.md)
- [keyType](accessorytransportextension/securitymessage/keytype-swift.property.md)
- [SecurityMessage.KeyType](accessorytransportextension/securitymessage/keytype-swift.enum.md)

### Determining encryption method

- [cipherSuite](accessorytransportextension/securitymessage/ciphersuite-swift.property.md)
- [version](accessorytransportextension/securitymessage/version.md)
- [SecurityMessage.CipherSuite](accessorytransportextension/securitymessage/ciphersuite-swift.enum.md)

### Specifying transport preferences

- [supportedTransports](accessorytransportextension/securitymessage/supportedtransports.md)

### Deriving HPKE keys

- [identifier](accessorytransportextension/securitymessage/identifier.md)

## Relationships

### Conforms To

- [CustomStringConvertible](swift/customstringconvertible.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Data and sessions

- [AccessoryFeature](accessorytransportextension/accessoryfeature.md)
- [AccessoryMessage](accessorytransportextension/accessorymessage.md)
- [AccessorySecuritySession](accessorytransportextension/accessorysecuritysession.md)
- [TransportMessage](accessorytransportextension/transportmessage.md)
- [AccessoryTransport](accessorytransportextension/accessorytransport.md)
