<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GSS",
  "identifier" : "/documentation/GSS/gss_encapsulate_token(_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "GSS"
    ],
    "preciseIdentifier" : "c:@F@gss_encapsulate_token"
  },
  "title" : "gss_encapsulate_token(_:_:_:)"
}
-->

# gss_encapsulate_token(_:_:_:)

Returns a buffer encapsulating the given token.

```
func gss_encapsulate_token(_ input_token: gss_const_buffer_t, _ oid: gss_const_OID, _ output_token: gss_buffer_t) -> OM_uint32
```

## Parameters

`input_token`

A buffer holding the token to be encapsulated.

`oid`

The token’s object identifier.

`output_token`

A buffer the function fills with the encapsulated token. Release this buffer’s memory with a call to [`gss_release_buffer(_:_:)`](/documentation/GSS/gss_release_buffer(_:_:)) when you are done with it.

## Return Value

A status code set to [`GSS_S_COMPLETE`](/documentation/GSS/GSS_S_COMPLETE) on success. See [Function Status](/documentation/GSS/function-status) for a complete enumeration of status outputs.

## Discussion

Use this function to encapsulate the initial token of a GSS-API context establishment sequence. It incorporates an identifier of the mechanism type used on that context, and enables unambiguous interpretation of tokens at GSS-API peers.

Use [`gss_decapsulate_token(_:_:_:)`](/documentation/GSS/gss_decapsulate_token(_:_:_:)) at the peer to reverse the encapsulation.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)