Important: The information in this document is obsolete and should not be used for new development.
Opening a Secure Connection
To open a secure ASDSP connection, both the initiator and the recipient must call thesdspOpenroutine after calling thedspInitroutine and, optionally, thedspOptionsroutine. First this section describes how the initiator part of an application opens a
secure connection. Then it describes how the recipient end of an application opens
a secure connection.From the Initiator's End
An initiator can send a request to open a secure session to
The initiator makes either an AOCE
- a specific socket whose client application has opened a connection end to wait passively for a connection request
- a connection listener whose function is to accept requests for secure connections and pass those requests on to a connection server
AuthTradeProxyForCredentialscall or an AOCEAuthGetCredentialscall to the authentication server. It passes to the authenti-
cation server its own name and the name of the recipient and gets back the session key and the credentials for the session. For an explanation of the calls that the initiator must make to the Authentication Manager, see the chapter "Authentication Manager" in Inside Macintosh: AOCE Application Programming Interfaces.Through the
sdspOpencall, the initiator passes the credentials to ASDSP to send to the recipient. ASDSP decrypts the credentials and passes the decrypted credential informa-
tion to the recipient.To open a secure ASDSP connection, the initiator performs the following procedure:
- Determine if the Apple Open Collaboration Environment (AOCE) software is installed by calling the
Gestaltfunction. See the chapter "Introduction to AOCE" in Inside Macintosh: AOCE Application Programming Interfaces for a description of the selector values that you use.- Allocate memory for the required data structures identified in this step. The memory belongs to ASDSP until the routine completes execution, after which you can either release or reuse the memory. You must either allocate nonrelocatable memory or lock the memory until the routine completes. See the chapter "Authentication Manager" in Inside Macintosh: AOCE Application Programming Interfaces for a description of the memory that you need to allocate for calls that you make to that interface. The data structures that you need to allocate memory for are listed here:
- An ASDSP parameter block of type
SDSPParamBlock. You pass a pointer to this parameter block as the value of theparamBlockparameter to thePBControlfunction. (See "The ASDSP Parameter Block" on page 5-41.)- A workspace buffer that the
sdspOpenroutine uses internally whose size is equal tosdspWorkSize. The memory for this buffer must be aligned on an even boundary. You pass a pointer to this buffer as the value of theworkspaceparameter.- A buffer for the credentials retrieved from the authentication server and passed
to ASDSP.- A buffer for the session key retrieved from the authentication server and passed to ASDSP. This is a data structure of type
AuthKey.
- Call the Authentication Manager's
AuthGetUTCTimefunction to get the universal coordinated time (UTC). You base the credentials expiration time that you specify
as input to theAuthGetCredentialsfunction on the UTC. See the chapter "Authentication Manager" for a description of theAuthGetUTCTimefunction.- Obtain your (the initiator's) identity and the recipient's record ID. (You can use the local identity or get a specific identity for the initiator.) You need to pass these values to the authentication server to get the session key and credential block from the server. See the chapter "Authentication Manager" for a discussion of identities and complete instruction on how to get these values.
- Call the Authentication Manager's
AuthGetCredentialsfunction orAuthTradeProxyForCredentialsfunction to get the credentials and the session key. You use these values as input to thesdspOpenroutine. See the chapter "Authentication Manager" for information on theAuthGetCredentialsandAuthTradeProxyForCredentialsfunctions.You pass the
AuthGetCredentialsfunction orAuthTradeProxyForCredentialsfunction the following values returned from the functions that you called in the previous steps:
- The initiator's identity.
- A pointer to a buffer containing the record ID for the recipient.
- The desired expiration time of the credentials. You use the
expiryparameter to specify for how long you want the credentials to be valid. Credentials are valid for at most eight hours after they are returned to the initiator by the server. You base the expiration time on the UTC time returned by theAuthGetUTCTimefunction.- The expected length of the credentials. A buffer three times the size of a packed record ID is usually sufficient for credentials. The AOCE constant
kPackedRecordIDMaxBytesspecifies the size of a single packed record ID.
- Call the
sdspOpenroutine to open a secure connection. To call thesdspOpenroutine, you call the Device Manager'sPBControlfunction and specifysdspOpenas the value of thecsCodeparameter. The parameter block for thesdspOpenroutine includes fields also used for the standarddspOpenroutine. In addition to these parameters, you specify parameters used in the authentication process to establish
the secure connection.The initiator application calls the
sdspOpenroutine with a value ofocRequestfor theocModeparameter to direct ASDSP to open a connection with a specific socket on the AppleTalk internet. When you execute thesdspOpenroutine in theocRequestmode, ASDSP sends an open-connection request to the address you specify.If the socket to which you send the open-connection request is a connection listener, the connection server that operates that connection listener can select any socket on the internet to be the connection end that responds to the open-connection request. To restrict the socket from which you will accept a response to your open-connection request, specify a value for the
filterAddressparameter to thesdspOpenroutine.To use the
ocRequestmode, you must know the complete internet address of the remote socket, and the ASDSP client at that address must either be a connection listener or have executed thesdspOpenroutine in theocPassivemode. You can use the NBP routines to obtain a list of the names of objects on the internet and to determine the internet address of a socket when you know its name. See the chapter "Name-Binding Protocol (NBP)" in this book for information on the NBP routines.In addition to the standard ADSP parameters required for a
dspOpencall, the initiator supplies the following input values to thesdspOpencall:
Parameter Value secure To open a secure authenticated connection, pass a value
ofTRUE. To open a normal, unauthenticated connection,
pass a value ofFALSE.sessionKey A pointer to the encryption key returned from
theAuthGetCredentialsorAuthTradeProxyForCredentialsfunction.credentialsSize The value that the AuthGetCredentialsfunction or
theAuthTradeProxyForCredentialsfunction returned that specifies the length of the credentials.credentials A pointer to the credentials that the AuthGetCredentialsfunction or theAuthTradeProxyForCredentialsfunction returned.workspace A pointer to the workspace buffer that you allocated, which is for ASDSP's internal use.
From the Recipient End
To open a secure ASDSP connection, the recipient performs the following procedure:
- Allocate memory for the following data structures. The memory belongs to ASDSP until the routine completes execution, after which you can either release or reuse the memory. You must either allocate nonrelocatable memory or lock the memory until the routine completes.
- An ASDSP secure parameter block of type
SDSPParamBlock. You pass a pointer to this parameter block as the value of theparamBlockparameter to thePBControlfunction. (See "The ASDSP Parameter Block" beginning on page 5-41.)- A workspace buffer that the
sdspOpenroutine uses internally whose size is equal tosdspWorkSize. The memory for this buffer must be aligned on an even boundary. You must pass a pointer to the buffer as the value of theworkspaceparameter.- A data structure of type
AuthKeyfor the session key retrieved from the authentica-
tion server and passed to ASDSP. ASDSP breaks out from the credentials block the session key encrypted in the recipient's private key and returns the session key to the recipient in thesessionKeybuffer.- A buffer for the record ID of the initiator that ASDSP returns to the recipient in response to the recipient's
sdspOpenroutine. You pass a pointer to this buffer as the value of theinitiatorparameter. ASDSP breaks out the initiator's record ID from the credential block that the initiator passes to ASDSP and returns it to the recipient. See the chapter "Authentication Manager" in Inside Macintosh: AOCE Application Programming Interfaces for a description of how to create a maximum-
size record ID structure that is large enough to hold any record ID.- A buffer for the record ID of the intermediary that ASDSP returns to the recipient if an intermediary is found in the credentials. You pass a pointer to this buffer as the value of the
intermediaryparameter. An intermediary is a proxy that has used theAuthTradeProxyForCredentialsfunction to obtain the credentials used in the authentication process. See the chapter "Authentication Manager" in Inside Macintosh: AOCE Application Programming Interfaces for a discussion of the use of an intermediary and theAuthTradeProxyForCredentialsfunction and for a description of how to create a maximum-size record ID structure that is large enough to hold any record ID.
- Call the
sdspOpenroutine to open a secure connection. To call thesdspOpenroutine, you call the Device Manager'sPBControlfunction and specifysdspOpenas the value of thecsCodeparameter. The parameter block for thesdspOpenroutine includes fields also used for the standarddspOpenroutine. In addition to these parameters, you specify parameters used in the authentication process to establish
the secure connection.A recipient end of a connection can be either a connection listener that listens for connection requests and passes them on to a connection server or a socket that waits passively to receive a connection request.
If the recipient is a connection listener, it calls the
sdspOpenroutine with a
value ofocAcceptfor theocModeparameter. The connection server accepts
and acknowledges receipt of a connection request. When you call thesdspOpenroutine, you must provide the values returned by thedspCLListenroutine
for theremoteCID,remoteAddress,sendSeq,sendWindow, andattnSendSeqparameters. You can poll thestatefield in the CCB to determine when the connection is open. Alternatively, you can check the result code for thesdspOpenroutine when the routine completes execution. If the routine returns thenoErr
result code, then the connection is open.If the recipient is a connection end associated with a passive socket that calls the
sdspOpenroutine with a value ofocPassivefor theocModeparameter, use theocPassivemode when you expect to receive an open-connection request from a remote socket. You can specify a value for thefilterAddressparameter to restrict the network number, node ID, or socket number from which you will accept an open-connection request.You can poll the state field in the CCB to determine when the connection end is waiting to receive an open-connection request, when the connection end is waiting to receive an acknowledgment of an open-connection request, and when the connection is open. See the section "The ADSP Connection Control Block Record" beginning on page 5-35 for a description of the CCB fields. Alternatively, you can check the result code for the
dspOpenroutine when the routine completes execution. If the routine returns thenoErrresult code, then the connection is open.In addition to the standard ADSP parameters required for a
dspOpencall, the recipient supplies the following input values to thesdspOpencall:
Parameter Value sessionKey A pointer to a data structure of type AuthKey, which you allocated. ASDSP copies the session key into this buffer if
an authenticated connection was successfully opened.workspace A pointer to the workspace buffer that you allocated, which is for ASDSP's internal use. recipient The identity of the recipient. initiator A pointer to a maximum-size record ID. ASDSP copies the initiator's record ID into this structure if an authenticated connection was successfully opened. intermediary A pointer to a maximum-size record ID. ASDSP copies the intermediary's record ID into this structure if an authenticated connection was successfully opened and an intermediary was used to obtain the credentials used to authenticate the call. If a secure connection was successfully opened, ASDSP returns the following values:
Parameter Value issueTime The time when the credentials were issued. ASDSP copies this value from the credentials. expiry The time when the credentials expire. ASDSP copies this value from the credentials. sessionKey The encryption key for the session. ASDSP copies this value from the credentials. initiator A pointer to a maximum-size record ID structure. If an authenticated connection was successfully opened, this structure holds the initiator's record ID. hasIntermediary A flag that is set to TRUEif an intermediary was used to obtain the credentials.intermediary A pointer to a maximum-size record ID. If an authentication connection was successfully opened and an intermediary was used to obtain the credentials, this structure holds the intermediary's record ID.
Sending Encrypted Data Across a Secure Connection
After a secure connection is established, both ends can send encrypted data over the session. ASDSP client applications use thedspWriteroutine to send data, encrypted
or not, over a secure connection. You can turn the encryption feature on or off on a message-by-message basis by setting one flag to direct ASDSP to encrypt the data and setting another flag to terminate the message.To set these flags, you use the bits of the end-of-message (
eom) field; this field is part of theioParamsvariant record of the DSP parameter block that you pass to thedspWriteroutine. For secure connections, theeomfield comprises these two single-bit flags instead of a zero-nonzero byte. You can use thedspEncryptMaskanddspEOMMaskmasks to set these flags, or you can use thedspEncryptBitordspEOMBitconstant.
The encryption process is transparent to the client application that receives the data; ASDSP determines if the received information is encrypted, and, if so, it decrypts the byte stream before copying the data to the read buffer specified by the
- Note
- Apart from the
dspWriteroutine'seomparameter, the interface to ADSP remains unchanged in regard to encryption.![]()
dspReadroutine.To write data that ASDSP encrypts and then transmits or to terminate data encryption, you call the
dspWriteroutine using the Device Manager'sPBControlfunction.
If you want to encrypt all messages, you can simply set the encrypt bit on all
- Set the encrypt bit of the
eomfield (bit 1) of the DSP parameter block. To set the encrypt bit, you use thedspEncryptMaskmask or thedspEncryptBitconstant. Note that ASDSP checks this flag on the first write of the connection or the first write following a write for which the end-of-message flag (bit 0 of theeomfield) is set.- Set the end-of-message bit (bit 0) of the
eomfield to terminate the encrypted message. To set the end-of-message bit, you use thedspEOMMaskmask or thedspEOMBitconstant.
dspWritecalls.