---
title: "tokenSession(_:sign:keyObjectID:algorithm:)"
framework: cryptotokenkit
role: symbol
role_heading: Instance Method
path: "cryptotokenkit/tktokensessiondelegate/tokensession(_:sign:keyobjectid:algorithm:)"
---

# tokenSession(_:sign:keyObjectID:algorithm:)

Tells the delegate to sign a data object using the specified key and algorithm.

## Declaration

```swift
optional func tokenSession(_ session: TKTokenSession, sign dataToSign: Data, keyObjectID: TKToken.ObjectID, algorithm: TKTokenKeyAlgorithm) throws -> Data
```

## Parameters

- `session`: The token session.
- `dataToSign`: The data to sign.
- `keyObjectID`: The identifier of the private key object.
- `algorithm`: The algorithm to be used for signing.

## Return Value

Return Value The signed data, or nil if an error occurred.

## See Also

### Performing Cryptographic Operations

- [tokenSession(_:decrypt:keyObjectID:algorithm:)](cryptotokenkit/tktokensessiondelegate/tokensession(_:decrypt:keyobjectid:algorithm:).md)
- [tokenSession(_:performKeyExchange:keyObjectID:algorithm:parameters:)](cryptotokenkit/tktokensessiondelegate/tokensession(_:performkeyexchange:keyobjectid:algorithm:parameters:).md)
- [TKTokenKeyExchangeParameters](cryptotokenkit/tktokenkeyexchangeparameters.md)
