User Tools

Site Tools


protocols:hf-pop

POP3 FOR USE OVER STANAG 5066 TRANSPORT (HF-POP3)

This section of this Annex presents an adaptation of the POP3 protocol, as described in RFC 1939, for use over the transport system described in the main body of and mandatory annexes to this STANAG. Large parts of the RFC are reproduced here, however there are differences so read carefully.

Introduction

It will in general be impractical to maintain a message transport system (MTS) over HF radio to allow immediate delivery of messages to a node when that node relies on HF radio for connectivity. It is still necessary to be able to manage the transfer of mail to these smaller nodes. To solve this problem, a node which can support an MTS entity offers a maildrop service to these less endowed nodes. The Post Office Protocol - Version 3 (POP3), as modified in this Annex, is intended to permit a workstation to dynamically access a maildrop on a server host over HF radio. Usually, this means that the POP3 protocol is used to allow a node to retrieve mail that the server is holding for it. This annex presents a revision of the POP3 protocol which is intended to provide efficient operation over HF radio links. This revised protocol will be referred to as “HF-POP” in this annex.

For the remainder of this annex, the term “client host” refers to a host making use of the HFPOP service, while the term “server host” refers to a host which offers the HF-POP service.

This annex does not specify how a client host enters mail into the transport system, although a method consistent with the philosophy of this annex is presented here:

When the user agent on a client host wishes to enter a message into the transport system, it establishes an HMTP connection to its relay host and sends all mail to it.

Basic Operation

Initially, the server host starts the HF-POP3 service by listening for incoming connections over the HF subnet. When a client host wishes to make use of the service, it establishes a connection with the server host. When the connection is established, the HF-POP3 server sends a greeting. The client and POP3 server then exchange commands and responses (respectively) until the connection is closed or aborted.

Commands in the HF-POP consist of a case-insensitive keyword, possibly followed by one or more arguments. All commands are terminated by a CRLF pair. Keywords and arguments consist of printable ASCII characters. Keywords and arguments are each separated by a single SPACE character. Keywords are three or four characters long. Each argument may be up to 40 characters long.

Responses in the HF-POP consist of a status indicator and a keyword possibly followed by additional information. All responses are terminated by a CRLF pair. Responses may be up to 512 characters long, including the terminating CRLF. There are two status indicators: positive (“+OK”) and negative (“-ERR”). Servers shall send the “+OK” and “-ERR” in upper case.

Responses to certain commands are multi-line. In these cases, which are clearly indicated below, after sending the first line of the response and a CRLF, any additional lines are sent, each terminated by a CRLF pair. When all lines of the response have been sent, a final line is sent, consisting of a termination octet (decimal code 046, “.”) and a CRLF pair. If any line of the multi-line response begins with the termination octet, the line is “byte-stuffed” by prepending the termination octet to that line of the response. Hence a multi-line response is terminated with the five octets “CRLF.CRLF”. When examining a multi-line response, the client checks to see if the line begins with the termination octet. If so and if octets other than CRLF follow, the first octet of the line (the termination octet) is stripped away. If so and if CRLF immediately follows the termination character, then the response from the POP server is ended and the line containing “.CRLF” is not considered part of the multi-line response.

A HF-POP3 session progresses through a number of states during its lifetime. Once the SnAP connection has been opened and the HF-POP3 server has sent the greeting, the session enters the AUTHORIZATION state. In this state, the client must identify itself to the HFPOP3 server. Once the client has successfully done this, the server acquires resources associated with the client's maildrop, and the session enters the TRANSACTION state. In this state, the client requests actions on the part of the HF-POP3 server. When the client has issued the QUIT command, the session enters the UPDATE state. In this state, the HF-POP3 server releases any resources acquired during the TRANSACTION state and says goodbye. The connection is then closed.

A server MUST respond to an unrecognized, unimplemented, or syntactically invalid command by responding with a negative status indicator. A server MUST respond to a command issued when the session is in an incorrect state by responding with a negative status indicator. There is no general method for a client to distinguish between a server which does not implement an optional command and a server which is unwilling or unable to process the command.

A HF-POP3 server MAY have an inactivity autologout timer. Such a timer MUST be of at least 10 minutes' duration. The receipt of any command from the client during that interval should suffice to reset the autologout timer. When the timer expires, the session does NOT enter the UPDATE state–the server should close the connection without removing any messages or sending any response to the client.

The AUTHORIZATION State

Once the connection has been opened by a HF-POP3 client, the HF-POP3 server shall issue a one line greeting as follows:

S: +OK HF-POP3 (STANAG 5066) server ready <process-ID.clock@hostname>

(Responses which do not conform to this format shall be interpreted by the HF_POP3 client as negative responses.) The HF-POP3 session is now in the AUTHORIZATION state. The client must now identify and authenticate itself to the HF-POP3 server. The APOP command shall be used for this purpose.

The APOP command

Usage:

APOP name digest

Arguments: A string identifying a mailbox and a MD5 digest string (both required)

Restrictions: May only be given in the AUTHORIZATION state after the POP3 greeting or after an unsuccessful USER or PASS command

Discussion:

In the context of this standard, the APOP command provides both origin authentication and replay protection. An HF-POP3 servers shall include a timestamp in its banner greeting. The syntax of the timestamp corresponds to the `msg-id' in [RFC822], and MUST be different each time the POP3 server issues a banner greeting. For example, on a UNIX implementation in which a separate UNIX process is used for each instance of a POP3 server, the syntax of the timestamp might be:

<process-ID.clock@hostname>

where `process-ID' is the decimal value of the process's PID, clock is the decimal value of the system clock, and hostname is the fully-qualified domain-name corresponding to the host where the POP3 server is running.

The POP3 client makes note of this timestamp, and then issues the APOP command. The `name' parameter has identical semantics to the `name' parameter of the USER command. The `digest' parameter is calculated by applying the MD5 algorithm [RFC1321] to a string consisting of the timestamp (including angle-brackets) followed by a shared secret. This shared secret is a string known only to the POP3 client and server. Great care should be taken to prevent unauthorized disclosure of the secret, as knowledge of the secret will allow any entity to successfully masquerade as the named user. The `digest' parameter itself is a 16-octet value which is sent in hexadecimal format, using lower-case ASCII characters.

When the POP3 server receives the APOP command, it verifies the digest provided. If the digest is correct, the POP3 session enters the TRANSACTION state and the POP3 server issues a positive response including the LIST response for the maildrop, as shown below. Otherwise, a negative response is issued and the POP3 session remains in the AUTHORIZATION state.

Note that as the length of the shared secret increases, so does the difficulty of deriving it. As such, shared secrets should be long strings (considerably longer than the 8-character example shown below).

Possible Responses:

S: +OK maildrop locked and ready; maildrop has 1 message (320 octets)
S: 1 120
S: 2 200
S: .
S: -ERR permission denied

Examples:

S: +OK POP3 server ready <1896.697170952@dbc.mtview.ca.us>
C: APOP mrose c4c9334bac560ecc979e58001b3e22fb
S: +OK maildrop has 1 message (369 octets)
S: 1 369

In this example, the shared secret is the string tanstaaf. Hence, the MD5 algorithm is applied to the string

<1896.697170952@dbc.mtview.ca.us>tanstaaf

which produces a digest value of c4c9334bac560ecc979e58001b3e22fb

Once the POP3 server has determined through the use of the APOP command that the client should be given access to the appropriate maildrop, the HF-POP3 server then acquires an exclusive-access lock on the maildrop, as necessary to prevent messages from being modified or removed before the session enters the UPDATE state. If the lock is successfully acquired, the POP3 server responds with a positive status indicator plus the response to the LIST command with no arguments (described in the following section on the TRANSACTION state). The HF-POP3 session now enters the TRANSACTION state, with no messages marked as deleted. If the maildrop cannot be opened for some reason (for example, a lock can not be acquired, the client is denied access to the appropriate maildrop, or the maildrop cannot be parsed), the HF-POP3 server responds with a negative status indicator. (If a lock was acquired but the HF-POP3 server intends to respond with a negative status indicator, the HF-POP3 server must release the lock prior to rejecting the command.) After returning a negative status indicator, the server may close the connection. If the server does not close the connection, the client may either issue a new authentication command and start again, or the client may issue the QUIT command.

After the HF-POP3 server has opened the maildrop, it assigns a message- number to each message, and notes the size of each message in octets. The first message in the maildrop is assigned a message-number of “1”, the second is assigned “2”, and so on, so that the nth message in a maildrop is assigned a message-number of “n”. In HF-POP3 commands and responses, all message-numbers and message sizes are expressed in base-10 (i.e., decimal).

The QUIT command

Here is the summary for the QUIT command when used in the AUTHORIZATION state:

QUIT

Arguments: none

Restrictions: none

Possible Responses:

+OK

Examples:

C: QUIT
S: +OK dewey POP3 server signing off

The TRANSACTION State

Once the client has successfully identified itself to the POP3 server and the POP3 server has locked and opened the appropriate maildrop, the POP3 session is now in the TRANSACTION state. Note that this transition occurs after the APOP line from the client is processed and before the server generates the UIDL response. The client may now issue any of the following POP3 commands repeatedly. After each command, the POP3 server issues a response. Eventually, the client issues the QUIT command and the POP3 session enters the UPDATE state.

Here are the POP3 commands valid in the TRANSACTION state:

The LIST Command

Usage:

LIST [msg]

Arguments: a message-number (optional), which, if present, may NOT refer to a message marked as deleted

Restrictions: may only be given in the TRANSACTION state

Discussion: If an argument was given and the POP3 server issues a positive response with a line containing information for that message. This line is called a “scan listing” for that message.

If no argument was given and the POP3 server issues a positive response, then the response given is multi-line. After the initial +OK, for each message in the maildrop, the POP3 server responds with a line containing information for that message. This line is also called a “scan listing” for that message. If there are no messages in the maildrop, then the POP3 server responds with no scan listings–it issues a positive response followed by a line containing a termination octet and a CRLF pair.

In order to simplify parsing, all POP3 servers are required to use a certain format for scan listings. A scan listing consists of the message-number of the message, followed by a single space and the exact size of the message in octets, followed by a CRLF pair. Methods for calculating the exact size of the message are described in the “Message Format” section of RFC 1939.

Note that messages marked as deleted are not listed.

Possible Responses:

+OK scan listing follows
-ERR no such message

Examples:

C: LIST
S: +OK 2 messages (320 octets)
S: 1 120
S: 2 200
S: .
...
C: LIST 2
S: +OK 2 200
...
C: LIST 3
S: -ERR no such message, only 2 messages in maildrop

The RETR Command

Usage:

RETR nn

Arguments: a message-number (optional) which may NOT refer to a message marked as deleted

Restrictions: may only be given in the TRANSACTION state

Discussion: If the POP3 server issues a positive response, then the response given is multi-line. If an argument was given, after the initial +OK, the POP3 server sends the message corresponding to the given message-number, being careful to byte-stuff the termination character (as with all multi-line responses). If no argument was given, the server sends all messages in the drop which are not marked as deleted. Use UIDL to identify boundary between messages? If so, need to include the UIDL response as part of the response to APOP.

Possible Responses:

+OK message nn follows
+OK m messages follow
-ERR no such message

Examples:

C: RETR 1
S: +OK 120 octets
S: <the POP3 server sends the entire message here>
S: .

The DELE Command

Usage:

DELE msg

Arguments: a message-number (required) which may NOT refer to a message marked as deleted Restrictions: may only be given in the TRANSACTION state

Discussion: The POP3 server marks the message as deleted. Any future reference to the message-number associated with the message in a POP3 command generates an error. The POP3 server does not actually delete the message until the POP3 session enters the UPDATE state.

Possible Responses:

+OK message deleted
-ERR no such message

Examples:

C: DELE 1
S: +OK message 1 deleted
...
C: DELE 2
S: -ERR message 2 already deleted

The RSET Command

Usage:

RSET

Arguments: none

Restrictions: may only be given in the TRANSACTION state

Discussion: If any messages have been marked as deleted by the POP3 server, they are unmarked. The POP3 server then replies with a positive response.

Possible Responses:

+OK

Examples:

C: RSET
S: +OK maildrop has 2 messages (320 octets)

The STAT Command

Usage:

STAT

Arguments: none

Restrictions:

may only be given in the TRANSACTION state

Discussion: The POP3 server issues a positive response with a line containing information for the maildrop. This line is called a “drop listing” for that maildrop.

In order to simplify parsing, all POP3 servers are required to use a certain format for drop listings. The positive response consists of “+OK” followed by a single space, the number of messages in the maildrop, a single space, the size of the maildrop in octets, and the line shall be terminated with a CRLF pair.

Note that messages marked as deleted are not counted in either total.

Possible Responses:

+OK nn mm

Examples:

C: STAT
S: +OK 2 320

The UIDL Command (OPTIONAL)

Usage:

UIDL [msg] 

Arguments: a message-number (optional), which, if present, may NOT refer to a message marked as deleted

Restrictions: may only be given in the TRANSACTION state.

Discussion: If an argument was given and the POP3 server issues a positive response with a line containing information for that message. This line is called a “unique-id listing” for that message.

If no argument was given, then the response given is multi-line. After the initial +OK, for each message in the maildrop, the HF-POP3 server responds with a line containing information for that message. This line is called a “unique-id listing” for that message.

In order to simplify parsing, all POP3 servers are required to use a certain format for unique-id listings. A unique-id listing consists of the message-number of the message, followed by a single space and the unique-id of the message. No information follows the unique-id in the unique-id listing.

The unique-id of a message is an arbitrary server-determined string, consisting of one to 70 characters in the range 0x21 to 0x7E, which uniquely identifies a message within a maildrop and which persists across sessions. This persistence is required even if a session ends without entering the UPDATE state. The server should never reuse an unique-id in a given maildrop, for as long as the entity using the unique-id exists.

Note that messages marked as deleted are not listed.

While it is generally preferable for server implementations to store arbitrarily assigned unique-ids in the maildrop, this specification is intended to permit uniqueids to be calculated as a hash of the message. Clients should be able to handle a situation where two identical copies of a message in a maildrop have the same unique-id.

Possible Responses:

+OK unique-id listing follows
-ERR no such message

Examples:

C: UIDL
S: +OK
S: 1 whqtswO00WBw418f9t5JxYwZ
S: 2 QhdPYR:00WBw1Ph7x7
S: .
...
C: UIDL 2
S: +OK 2 QhdPYR:00WBw1Ph7x7
...
C: UIDL 3
S: -ERR no such message, only 2 messages in maildrop

The UPDATE State

When the client issues the QUIT command from the TRANSACTION state, the POP3 session enters the UPDATE state. (Note that if the client issues the QUIT command from the AUTHORIZATION state, the POP3 session terminates but does NOT enter the UPDATE state.)

If a session terminates for some reason other than a client-issued QUIT command, the POP3 session does NOT enter the UPDATE state and MUST not remove any messages from the maildrop.

The QUIT Command

Usage:

QUIT

Arguments: none

Restrictions: none

Discussion: The POP3 server removes all messages marked as deleted from the maildrop and replies as to the status of this operation. If there is an error, such as a resource shortage, encountered while removing messages, the maildrop may result in having some or none of the messages marked as deleted be removed. In no case may the server remove any messages not marked as deleted.

Whether the removal was successful or not, the server then releases any exclusiveaccess lock on the maildrop and closes the connection

Possible Responses:

+OK
-ERR some deleted messages not removed

Examples:

C: QUIT
S: +OK dewey POP3 server signing off (maildrop empty)
...
C: QUIT
S: +OK dewey POP3 server signing off (2 messages left)
...

The TOP Command

Usage:

TOP msg n

Arguments: a message-number (required) which may NOT refer to to a message marked as deleted, and a non-negative number of lines (required)

Restrictions: may only be given in the TRANSACTION state

Discussion: If the POP3 server issues a positive response, then the response given is multi-line. After the initial +OK, the POP3 server sends the headers of the message, the blank line separating the headers from the body, and then the number of lines of the indicated message's body, being careful to byte-stuff the termination character (as with all multi-line responses).

Note that if the number of lines requested by the POP3 client is greater than than the number of lines in the body, then the POP3 server sends the entire message.

Possible Responses:

+OK top of message follows
-ERR no such message

Examples:

C: TOP 1 10
S: +OK
S: <the POP3 server sends the headers of the message, a blank line, and the first 10
lines of the body of the message>
S: .
...
C: TOP 100 3
S: -ERR no such message

Scaling and Operational Considerations

The HF-POP3 protocol implements a special case of a site policy in order to prevent users from accumulating large mail queues on the server system. These large queues can result in a full disk and system crashes; this problem is frequently observed in POP3 servers. Messages may only be downloaded once from the server, and shall be deleted after this has been accomplished. This could be implemented in HF-POP3 server software by the following mechanism: “following a POP3 login by a client which was ended by a QUIT, delete all messages downloaded during the session with the RETR command”. It is important not to delete messages in the event of abnormal connection termination (ie, if no QUIT was received from the client) because the client may not have successfully received or stored the messages. Servers implementing a download-and-delete policy may also wish to disable or limit the optional TOP command, since it could be used as an alternate mechanism to download entire messages.

protocols/hf-pop.txt · Last modified: 2018/08/20 12:43 by root

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki