home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1997 December / Internet_Info_CD-ROM_Walnut_Creek_December_1997.iso / drafts / draft_ietf_a_c / draft-ietf-cat-ftpsec-09.txt < prev    next >
Text File  |  1996-11-26  |  56KB  |  1,363 lines

  1.  
  2. Network Working Group                                        M. Horowitz
  3. <draft-ietf-cat-ftpsec-09.txt>                          Cygnus Solutions
  4. Updates: RFC 959                                              S. J. Lunt
  5. Internet-Draft                                                  Bellcore
  6. Expire in six months                                      November, 1996
  7.  
  8.                         FTP Security Extensions
  9.  
  10. Status of this Memo
  11.  
  12.    This document is an Internet-Draft.  Internet-Drafts are working
  13.    documents of the Internet Engineering Task Force (IETF), its areas,
  14.    and its working groups.  Note that other groups may also distribute
  15.    working documents as Internet-Drafts.
  16.  
  17.    Internet-Drafts are draft documents valid for a maximum of six months
  18.    and may be updated, replaced, or obsoleted by other documents at any
  19.    time.  It is inappropriate to use Internet-Drafts as reference
  20.    material or to cite them other than as ``work in progress.''
  21.  
  22.    To learn the current status of any Internet-Draft, please check the
  23.    ``1id-abstracts.txt'' listing contained in the Internet-Drafts Shadow
  24.    Directories on ds.internic.net (US East Coast), nic.nordu.net
  25.    (Europe), ftp.isi.edu (US West Coast), or munnari.oz.au (Pacific
  26.    Rim).
  27.  
  28.    Distribution of this memo is unlimited.  Please send comments to the
  29.    <cat-ietf@mit.edu> mailing list.
  30.  
  31. Abstract
  32.  
  33.    This document defines extensions to the FTP specification RFC 959,
  34.    "FILE TRANSFER PROTOCOL (FTP)" (October 1985).  These extensions
  35.    provide strong authentication, integrity, and confidentiality on both
  36.    the control and data channels with the introduction of new optional
  37.    commands, replies, and file transfer encodings.
  38.  
  39.    The following new optional commands are introduced in this
  40.    specification:
  41.  
  42.       AUTH (Authentication/Security Mechanism),
  43.       ADAT (Authentication/Security Data),
  44.       PROT (Data Channel Protection Level),
  45.       PBSZ (Protection Buffer Size),
  46.       CCC (Clear Command Channel),
  47.       MIC (Integrity Protected Command),
  48.       CONF (Confidentiality Protected Command), and
  49.       ENC (Privacy Protected Command).
  50.  
  51.    A new class of reply types (6yz) is also introduced for protected
  52.    replies.
  53.  
  54.    None of the above commands are required to be implemented, but
  55.    interdependencies exist.  These dependencies are documented with the
  56.  
  57.  
  58.  
  59. Horowitz & Lunt                                                 [Page 1]
  60.  
  61. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  62.  
  63.  
  64.    commands.
  65.  
  66.    Note that this specification is compatible with RFC 959.
  67.  
  68.  
  69. 1.  Introduction
  70.  
  71.    The File Transfer Protocol (FTP) currently defined in RFC 959 and in
  72.    place on the Internet uses usernames and passwords passed in
  73.    cleartext to authenticate clients to servers (via the USER and PASS
  74.    commands).  Except for services such as 'anonymous' FTP archives,
  75.    this represents a security risk whereby passwords can be stolen
  76.    through monitoring of local and wide-area networks.  This either aids
  77.    potential attackers through password exposure and/or limits
  78.    accessibility of files by FTP servers who cannot or will not accept
  79.    the inherent security risks.
  80.  
  81.    Aside from the problem of authenticating users in a secure manner,
  82.    there is also the problem of authenticating servers, protecting
  83.    sensitive data and/or verifying its integrity.  An attacker may be
  84.    able to access valuable or sensitive data merely by monitoring a
  85.    network, or through active means may be able to delete or modify the
  86.    data being transferred so as to corrupt its integrity.  An active
  87.    attacker may also initiate spurious file transfers to and from a site
  88.    of the attacker's choice, and may invoke other commands on the
  89.    server.  FTP does not currently have any provision for the encryption
  90.    or verification of the authenticity of commands, replies, or
  91.    transferred data.  Note that these security services have value even
  92.    to anonymous file access.
  93.  
  94.    Current practice for sending files securely is generally either:
  95.  
  96.       1.  via FTP of files pre-encrypted under keys which are manually
  97.           distributed,
  98.  
  99.       2.  via electronic mail containing an encoding of a file encrypted
  100.           under keys which are manually distributed,
  101.  
  102.       3.  via a PEM message, or
  103.  
  104.       4.  via the rcp command enhanced to use Kerberos.
  105.  
  106.    None of these means could be considered even a de facto standard, and
  107.    none are truly interactive.  A need exists to securely transfer files
  108.    using FTP in a secure manner which is supported within the FTP
  109.    protocol in a consistent manner and which takes advantage of existing
  110.    security infrastructure and technology.  Extensions are necessary to
  111.    the FTP specification if these security services are to be introduced
  112.    into the protocol in an interoperable way.
  113.  
  114.    Although the FTP control connection follows the Telnet protocol, and
  115.    Telnet has defined an authentication and encryption option [TELNET-
  116.    SEC], [RFC-1123] explicitly forbids the use of Telnet option
  117.    negotiation over the control connection (other than Synch and IP).
  118.  
  119.  
  120.  
  121. Horowitz & Lunt                                                 [Page 2]
  122.  
  123. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  124.  
  125.  
  126.    Also, the Telnet authentication and encryption option does not
  127.    provide for integrity protection only (without confidentiality), and
  128.    does not address the protection of the data channel.
  129.  
  130.  
  131. 2.  FTP Security Overview
  132.  
  133.    At the highest level, the FTP security extensions seek to provide an
  134.    abstract mechanism for authenticating and/or authorizing connections,
  135.    and integrity and/or confidentiality protecting commands, replies,
  136.    and data transfers.
  137.  
  138.    In the context of FTP security, authentication is the establishment
  139.    of a client's identity and/or a server's identity in a secure way,
  140.    usually using cryptographic techniques.  The basic FTP protocol does
  141.    not have a concept of authentication.
  142.  
  143.    Authorization is the process of validating a user for login.  The
  144.    basic authorization process involves the USER, PASS, and ACCT
  145.    commands.  With the FTP security extensions, authentication
  146.    established using a security mechanism may also be used to make the
  147.    authorization decision.
  148.  
  149.    Without the security extensions, authentication of the client, as
  150.    this term is usually understood, never happens.  FTP authorization is
  151.    accomplished with a password, passed on the network in the clear as
  152.    the argument to the PASS command.  The possessor of this password is
  153.    assumed to be authorized to transfer files as the user named in the
  154.    USER command, but the identity of the client is never securely
  155.    established.
  156.  
  157.    An FTP security interaction begins with a client telling the server
  158.    what security mechanism it wants to use with the AUTH command.  The
  159.    server will either accept this mechanism, reject this mechanism, or,
  160.    in the case of a server which does not implement the security
  161.    extensions, reject the command completely.  The client may try
  162.    multiple security mechanisms until it requests one which the server
  163.    accepts.  This allows a rudimentary form of negotiation to take
  164.    place.  (If more complex negotiation is desired, this may be
  165.    implemented as a security mechanism.)  The server's reply will
  166.    indicate if the client must respond with additional data for the
  167.    security mechanism to interpret.  If none is needed, this will
  168.    usually mean that the mechanism is one where the password (specified
  169.    by the PASS command) is to be interpreted differently, such as with a
  170.    token or one-time password system.
  171.  
  172.    If the server requires additional security information, then the
  173.    client and server will enter into a security data exchange.  The
  174.    client will send an ADAT command containing the first block of
  175.    security data.  The server's reply will indicate if the data exchange
  176.    is complete, if there was an error, or if more data is needed.  The
  177.    server's reply can optionally contain security data for the client to
  178.    interpret.  If more data is needed, the client will send another ADAT
  179.    command containing the next block of data, and await the server's
  180.  
  181.  
  182.  
  183. Horowitz & Lunt                                                 [Page 3]
  184.  
  185. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  186.  
  187.  
  188.    reply.  This exchange can continue as many times as necessary.  Once
  189.    this exchange completes, the client and server have established a
  190.    security association.  This security association may include
  191.    authentication (client, server, or mutual) and keying information for
  192.    integrity and/or confidentiality, depending on the mechanism in use.
  193.  
  194.    The term ``security data'' here is carefully chosen.  The purpose of
  195.    the security data exchange is to establish a security association,
  196.    which might not actually include any authentication at all, between
  197.    the client and the server as described above.  For instance, a
  198.    Diffie-Hellman exchange establishes a secret key, but no
  199.    authentication takes place.  If an FTP server has an RSA key pair but
  200.    the client does not, then the client can authenticate the server, but
  201.    the server cannot authenticate the client.
  202.  
  203.    Once a security association is established, authentication which is a
  204.    part of this association may be used instead of or in addition to the
  205.    standard username/password exchange for authorizing a user to connect
  206.    to the server.  A username specified by the USER command is always
  207.    required to specify the identity to be used on the server.
  208.  
  209.    In order to prevent an attacker from inserting or deleting commands
  210.    on the control stream, if the security association supports
  211.    integrity, then the server and client must use integrity protection
  212.    on the control stream, unless it first transmits a CCC command to
  213.    turn off this requirement.  Integrity protection is performed with
  214.    the MIC and ENC commands, and the 63z reply codes.  The CCC command
  215.    and its reply must be transmitted with integrity protection.
  216.    Commands and replies may be transmitted without integrity (that is,
  217.    in the clear or with confidentiality only) only if no security
  218.    association is established, the negotiated security association does
  219.    not support integrity, or the CCC command has succeeded.
  220.  
  221.    Once the client and server have negotiated with the PBSZ command an
  222.    acceptable buffer size for encapsulating protected data over the data
  223.    channel, the security mechanism may also be used to protect data
  224.    channel transfers.
  225.  
  226.    Policy is not specified by this document.  In particular, client and
  227.    server implementations may choose to implement restrictions on what
  228.    operations can be performed depending on the security association
  229.    which exists.  For example, a server may require that a client
  230.    authorize via a security mechanism rather than using a password,
  231.    require that the client provide a one-time password from a token,
  232.    require at least integrity protection on the command channel, or
  233.    require that certain files only be transmitted encrypted.  An
  234.    anonymous ftp client might refuse to do file transfers without
  235.    integrity protection in order to insure the validity of files
  236.    downloaded.
  237.  
  238.    No particular set of functionality is required, except as
  239.    dependencies described in the next section.  This means that none of
  240.    authentication, integrity, or confidentiality are required of an
  241.    implementation, although a mechanism which does none of these is not
  242.  
  243.  
  244.  
  245. Horowitz & Lunt                                                 [Page 4]
  246.  
  247. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  248.  
  249.  
  250.    of much use.  For example, it is acceptable for a mechanism to
  251.    implement only integrity protection, one-way authentication and/or
  252.    encryption, encryption without any authentication or integrity
  253.    protection, or any other subset of functionality if policy or
  254.    technical considerations make this desirable.  Of course, one peer
  255.    might require as a matter of policy stronger protection than the
  256.    other is able to provide, preventing perfect interoperability.
  257.  
  258.  
  259. 3.  New FTP Commands
  260.  
  261.    The following commands are optional, but dependent on each other.
  262.    They are extensions to the FTP Access Control Commands.
  263.  
  264.    The reply codes documented here are generally described as
  265.    recommended, rather than required.  The intent is that reply codes
  266.    describing the full range of success and failure modes exist, but
  267.    that servers be allowed to limit information presented to the client.
  268.    For example, a server might implement a particular security
  269.    mechanism, but have a policy restriction against using it.  The
  270.    server should respond with a 534 reply code in this case, but may
  271.    respond with a 504 reply code if it does not wish to divulge that the
  272.    disallowed mechanism is supported.  If the server does choose to use
  273.    a different reply code than the recommended one, it should try to use
  274.    a reply code which only differs in the last digit.  In all cases, the
  275.    server must use a reply code which is documented as returnable from
  276.    the command received, and this reply code must begin with the same
  277.    digit as the recommended reply code for the situation.
  278.  
  279.    AUTHENTICATION/SECURITY MECHANISM (AUTH)
  280.  
  281.       The argument field is a Telnet string identifying a supported
  282.       mechanism.  This string is case-insensitive.  Values must be
  283.       registered with the IANA, except that values beginning with "X-"
  284.       are reserved for local use.
  285.  
  286.       If the server does not recognize the AUTH command, it must respond
  287.       with reply code 500.  This is intended to encompass the large
  288.       deployed base of non-security-aware ftp servers, which will
  289.       respond with reply code 500 to any unrecognized command.  If the
  290.       server does recognize the AUTH command but does not implement the
  291.       security extensions, it should respond with reply code 502.
  292.  
  293.       If the server does not understand the named security mechanism, it
  294.       should respond with reply code 504.
  295.  
  296.       If the server is not willing to accept the named security
  297.       mechanism, it should respond with reply code 534.
  298.  
  299.       If the server is not able to accept the named security mechanism,
  300.       such as if a required resource is unavailable, it should respond
  301.       with reply code 431.
  302.  
  303.       If the server is willing to accept the named security mechanism,
  304.  
  305.  
  306.  
  307. Horowitz & Lunt                                                 [Page 5]
  308.  
  309. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  310.  
  311.  
  312.       but requires security data, it must respond with reply code 334.
  313.  
  314.       If the server is willing to accept the named security mechanism,
  315.       and does not require any security data, it must respond with reply
  316.       code 234.
  317.  
  318.       If the server is responding with a 334 reply code, it may include
  319.       security data as described in the next section.
  320.  
  321.       Some servers will allow the AUTH command to be reissued in order
  322.       to establish new authentication.  The AUTH command, if accepted,
  323.       removes any state associated with prior FTP Security commands.
  324.       The server must also require that the user reauthorize (that is,
  325.       reissue some or all of the USER, PASS, and ACCT commands) in this
  326.       case (see section 4 for an explanation of "authorize" in this
  327.       context).
  328.  
  329.    AUTHENTICATION/SECURITY DATA (ADAT)
  330.  
  331.       The argument field is a Telnet string representing base 64 encoded
  332.       security data (see Section 9, "Base 64 Encoding").  If a reply
  333.       code indicating success is returned, the server may also use a
  334.       string of the form "ADAT=base64data" as the text part of the reply
  335.       if it wishes to convey security data back to the client.
  336.  
  337.       The data in both cases is specific to the security mechanism
  338.       specified by the previous AUTH command.  The ADAT command, and the
  339.       associated replies, allow the client and server to conduct an
  340.       arbitrary security protocol.  The security data exchange must
  341.       include enough information for both peers to be aware of which
  342.       optional features are available.  For example, if the client does
  343.       not support data encryption, the server must be made aware of
  344.       this, so it will know not to send encrypted command channel
  345.       replies.  It is strongly recommended that the security mechanism
  346.       provide sequencing on the command channel, to insure that commands
  347.       are not deleted, reordered, or replayed.
  348.  
  349.       The ADAT command must be preceded by a successful AUTH command,
  350.       and cannot be issued once a security data exchange completes
  351.       (successfully or unsuccessfully), unless it is preceded by an AUTH
  352.       command to reset the security state.
  353.  
  354.       If the server has not yet received an AUTH command, or if a prior
  355.       security data exchange completed, but the security state has not
  356.       been reset with an AUTH command, it should respond with reply code
  357.       503.
  358.  
  359.       If the server cannot base 64 decode the argument, it should
  360.       respond with reply code 501.
  361.  
  362.       If the server rejects the security data (if a checksum fails, for
  363.       instance), it should respond with reply code 535.
  364.  
  365.       If the server accepts the security data, and requires additional
  366.  
  367.  
  368.  
  369. Horowitz & Lunt                                                 [Page 6]
  370.  
  371. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  372.  
  373.  
  374.       data, it should respond with reply code 335.
  375.  
  376.       If the server accepts the security data, but does not require any
  377.       additional data (i.e., the security data exchange has completed
  378.       successfully), it must respond with reply code 235.
  379.  
  380.       If the server is responding with a 235 or 335 reply code, then it
  381.       may include security data in the text part of the reply as
  382.       specified above.
  383.  
  384.       If the ADAT command returns an error, the security data exchange
  385.       will fail, and the client must reset its internal security state.
  386.       If the client becomes unsynchronized with the server (for example,
  387.       the server sends a 234 reply code to an AUTH command, but the
  388.       client has more data to transmit), then the client must reset the
  389.       server's security state.
  390.  
  391.    PROTECTION BUFFER SIZE (PBSZ)
  392.  
  393.       The argument is a decimal integer representing the maximum size,
  394.       in bytes, of the encoded data blocks to be sent or received during
  395.       file transfer.  This number shall be no greater than can be
  396.       represented in a 32-bit unsigned integer.
  397.  
  398.       This command allows the FTP client and server to negotiate a
  399.       maximum protected buffer size for the connection.  There is no
  400.       default size; the client must issue a PBSZ command before it can
  401.       issue the first PROT command.
  402.  
  403.       The PBSZ command must be preceded by a successful security data
  404.       exchange.
  405.  
  406.       If the server cannot parse the argument, or if it will not fit in
  407.       32 bits, it should respond with a 501 reply code.
  408.  
  409.       If the server has not completed a security data exchange with the
  410.       client, it should respond with a 503 reply code.
  411.  
  412.       Otherwise, the server must reply with a 200 reply code.  If the
  413.       size provided by the client is too large for the server, it must
  414.       use a string of the form "PBSZ=number" in the text part of the
  415.       reply to indicate a smaller buffer size.  The client and the
  416.       server must use the smaller of the two buffer sizes if both buffer
  417.       sizes are specified.
  418.  
  419.    DATA CHANNEL PROTECTION LEVEL (PROT)
  420.  
  421.       The argument is a single Telnet character code specifying the data
  422.       channel protection level.
  423.  
  424.       This command indicates to the server what type of data channel
  425.       protection the client and server will be using.  The following
  426.       codes are assigned:
  427.  
  428.  
  429.  
  430.  
  431. Horowitz & Lunt                                                 [Page 7]
  432.  
  433. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  434.  
  435.  
  436.          C - Clear
  437.          S - Safe
  438.          E - Confidential
  439.          P - Private
  440.  
  441.       The default protection level if no other level is specified is
  442.       Clear.  The Clear protection level indicates that the data channel
  443.       will carry the raw data of the file transfer, with no security
  444.       applied.  The Safe protection level indicates that the data will
  445.       be integrity protected.  The Confidential protection level
  446.       indicates that the data will be confidentiality protected.  The
  447.       Private protection level indicates that the data will be integrity
  448.       and confidentiality protected.
  449.  
  450.       It is reasonable for a security mechanism not to provide all data
  451.       channel protection levels.  It is also reasonable for a mechanism
  452.       to provide more protection at a level than is required (for
  453.       instance, a mechanism might provide Confidential protection, but
  454.       include integrity-protection in that encoding, due to API or other
  455.       considerations).
  456.  
  457.       The PROT command must be preceded by a successful protection
  458.       buffer size negotiation.
  459.  
  460.       If the server does not understand the specified protection level,
  461.       it should respond with reply code 504.
  462.  
  463.       If the current security mechanism does not support the specified
  464.       protection level, the server should respond with reply code 536.
  465.  
  466.       If the server has not completed a protection buffer size
  467.       negotiation with the client, it should respond with a 503 reply
  468.       code.
  469.  
  470.       The PROT command will be rejected and the server should reply 503
  471.       if no previous PBSZ command was issued.
  472.  
  473.       If the server is not willing to accept the specified protection
  474.       level, it should respond with reply code 534.
  475.  
  476.       If the server is not able to accept the specified protection
  477.       level, such as if a required resource is unavailable, it should
  478.       respond with reply code 431.
  479.  
  480.       Otherwise, the server must reply with a 200 reply code to indicate
  481.       that the specified protection level is accepted.
  482.  
  483.    CLEAR COMMAND CHANNEL (CCC)
  484.  
  485.       This command does not take an argument.
  486.  
  487.       It is desirable in some environments to use a security mechanism
  488.       to authenticate and/or authorize the client and server, but not to
  489.       perform any integrity checking on the subsequent commands.  This
  490.  
  491.  
  492.  
  493. Horowitz & Lunt                                                 [Page 8]
  494.  
  495. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  496.  
  497.  
  498.       might be used in an environment where IP security is in place,
  499.       insuring that the hosts are authenticated and that TCP streams
  500.       cannot be tampered, but where user authentication is desired.
  501.  
  502.       If unprotected commands are allowed on any connection, then an
  503.       attacker could insert a command on the control stream, and the
  504.       server would have no way to know that it was invalid.  In order to
  505.       prevent such attacks, once a security data exchange completes
  506.       successfully, if the security mechanism supports integrity, then
  507.       integrity (via the MIC or ENC command, and 631 or 632 reply) must
  508.       be used, until the CCC command is issued to enable non-integrity
  509.       protected control channel messages.  The CCC command itself must
  510.       be integrity protected.
  511.  
  512.       Once the CCC command completes successfully, if a command is not
  513.       protected, then the reply to that command must also not be
  514.       protected.  This is to support interoperability with clients which
  515.       do not support protection once the CCC command has been issued.
  516.  
  517.       This command must be preceded by a successful security data
  518.       exchange.
  519.  
  520.       If the command is not integrity-protected, the server must respond
  521.       with a 533 reply code.
  522.  
  523.       If the server is not willing to turn off the integrity
  524.       requirement, it should respond with a 534 reply code.
  525.  
  526.       Otherwise, the server must reply with a 200 reply code to indicate
  527.       that unprotected commands and replies may now be used on the
  528.       command channel.
  529.  
  530.    INTEGRITY PROTECTED COMMAND (MIC) and
  531.    CONFIDENTIALITY PROTECTED COMMAND (CONF) and
  532.    PRIVACY PROTECTED COMMAND (ENC)
  533.  
  534.       The argument field of MIC is a Telnet string consisting of a base
  535.       64 encoded "safe" message produced by a security mechanism
  536.       specific message integrity procedure.  The argument field of CONF
  537.       is a Telnet string consisting of a base 64 encoded "confidential"
  538.       message produced by a security mechanism specific confidentiality
  539.       procedure.  The argument field of ENC is a Telnet string
  540.       consisting of a base 64 encoded "private" message produced by a
  541.       security mechanism specific message integrity and confidentiality
  542.       procedure.
  543.  
  544.       The server will decode and/or verify the encoded message.
  545.  
  546.       This command must be preceded by a successful security data
  547.       exchange.
  548.  
  549.       A server may require that the first command after a successful
  550.       security data exchange be CCC, and not implement the protection
  551.       commands at all.  In this case, the server should respond with a
  552.  
  553.  
  554.  
  555. Horowitz & Lunt                                                 [Page 9]
  556.  
  557. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  558.  
  559.  
  560.       502 reply code.
  561.  
  562.       If the server cannot base 64 decode the argument, it should
  563.       respond with a 501 reply code.
  564.  
  565.       If the server has not completed a security data exchange with the
  566.       client, it should respond with a 503 reply code.
  567.  
  568.       If the server has completed a security data exchange with the
  569.       client using a mechanism which supports integrity, and requires a
  570.       CCC command due to policy or implementation limitations, it should
  571.       respond with a 503 reply code.
  572.  
  573.       If the server rejects the command because it is not supported by
  574.       the current security mechanism, the server should respond with
  575.       reply code 537.
  576.  
  577.       If the server rejects the command (if a checksum fails, for
  578.       instance), it should respond with reply code 535.
  579.  
  580.       If the server is not willing to accept the command (if privacy is
  581.       required by policy, for instance, or if a CONF command is received
  582.       before a CCC command), it should respond with reply code 533.
  583.  
  584.       Otherwise, the command will be interpreted as an FTP command.  An
  585.       end-of-line code need not be included, but if one is included, it
  586.       must be a Telnet end-of-line code, not a local end-of-line code.
  587.  
  588.       The server may require that, under some or all circumstances, all
  589.       commands be protected.  In this case, it should make a 533 reply
  590.       to commands other than MIC, CONF, and ENC.
  591.  
  592.  
  593. 4.  Login Authorization
  594.  
  595.    The security data exchange may, among other things, establish the
  596.    identity of the client in a secure way to the server.  This identity
  597.    may be used as one input to the login authorization process.
  598.  
  599.    In response to the FTP login commands (AUTH, PASS, ACCT), the server
  600.    may choose to change the sequence of commands and replies specified
  601.    by RFC 959 as follows.  There are also some new replies available.
  602.  
  603.    If the server is willing to allow the user named by the USER command
  604.    to log in based on the identity established by the security data
  605.    exchange, it should respond with reply code 232.
  606.  
  607.    If the security mechanism requires a challenge/response password, it
  608.    should respond to the USER command with reply code 336.  The text
  609.    part of the reply should contain the challenge.  The client must
  610.    display the challenge to the user before prompting for the password
  611.    in this case.  This is particularly relevant to more sophisticated
  612.    clients or graphical user interfaces which provide dialog boxes or
  613.    other modal input.  These clients should be careful not to prompt for
  614.  
  615.  
  616.  
  617. Horowitz & Lunt                                                [Page 10]
  618.  
  619. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  620.  
  621.  
  622.    the password before the username has been sent to the server, in case
  623.    the user needs the challenge in the 336 reply to construct a valid
  624.    password.
  625.  
  626.  
  627. 5.  New FTP Replies
  628.  
  629.    The new reply codes are divided into two classes.  The first class is
  630.    new replies made necessary by the new FTP Security commands.  The
  631.    second class is a new reply type to indicate protected replies.
  632.  
  633.  
  634.    5.1.  New individual reply codes
  635.  
  636.       232 User logged in, authorized by security data exchange.
  637.       234 Security data exchange complete.
  638.       235 [ADAT=base64data]
  639.             ; This reply indicates that the security data exchange
  640.             ; completed successfully.  The square brackets are not
  641.             ; to be included in the reply, but indicate that
  642.             ; security data in the reply is optional.
  643.  
  644.       334 [ADAT=base64data]
  645.             ; This reply indicates that the requested security mechanism
  646.             ; is ok, and includes security data to be used by the client
  647.             ; to construct the next command.  The square brackets are not
  648.             ; to be included in the reply, but indicate that
  649.             ; security data in the reply is optional.
  650.       335 [ADAT=base64data]
  651.             ; This reply indicates that the security data is
  652.             ; acceptable, and more is required to complete the
  653.             ; security data exchange.  The square brackets
  654.             ; are not to be included in the reply, but indicate
  655.             ; that security data in the reply is optional.
  656.       336 Username okay, need password.  Challenge is "...."
  657.             ; The exact representation of the challenge should be chosen
  658.             ; by the mechanism to be sensible to the human user of the
  659.             ; system.
  660.  
  661.       431 Need some unavailable resource to process security.
  662.  
  663.       533 Command protection level denied for policy reasons.
  664.       534 Request denied for policy reasons.
  665.       535 Failed security check (hash, sequence, etc).
  666.       536 Requested PROT level not supported by mechanism.
  667.       537 Command protection level not supported by security mechanism.
  668.  
  669.  
  670.    5.2.  Protected replies.
  671.  
  672.       One new reply type is introduced:
  673.  
  674.          6yz   Protected reply
  675.  
  676.  
  677.  
  678.  
  679. Horowitz & Lunt                                                [Page 11]
  680.  
  681. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  682.  
  683.  
  684.             There are three reply codes of this type.  The first, reply
  685.             code 631 indicates an integrity protected reply.  The
  686.             second, reply code 632, indicates a confidentiality and
  687.             integrity protected reply.  the third, reply code 633,
  688.             indicates a confidentiality protected reply.
  689.  
  690.             The text part of a 631 reply is a Telnet string consisting
  691.             of a base 64 encoded "safe" message produced by a security
  692.             mechanism specific message integrity procedure.  The text
  693.             part of a 632 reply is a Telnet string consisting of a base
  694.             64 encoded "private" message produced by a security
  695.             mechanism specific message confidentiality and integrity
  696.             procedure.  The text part of a 633 reply is a Telnet string
  697.             consisting of a base 64 encoded "confidential" message
  698.             produced by a security mechanism specific message
  699.             confidentiality procedure.
  700.  
  701.             The client will decode and verify the encoded reply.  How
  702.             failures decoding or verifying replies are handled is
  703.             implementation-specific.  An end-of-line code need not be
  704.             included, but if one is included, it must be a Telnet end-
  705.             of-line code, not a local end-of-line code.
  706.  
  707.             A protected reply may only be sent if a security data
  708.             exchange has succeeded.
  709.  
  710.             The 63z reply may be a multiline reply.  In this case, the
  711.             plaintext reply must be broken up into a number of
  712.             fragments.  Each fragment must be protected, then base 64
  713.             encoded in order into a separate line of the multiline
  714.             reply.  There need not be any correspondence between the
  715.             line breaks in the plaintext reply and the encoded reply.
  716.             Telnet end-of-line codes must appear in the plaintext of the
  717.             encoded reply, except for the final end-of-line code, which
  718.             is optional.
  719.  
  720.             The multiline reply must be formatted more strictly than the
  721.             continuation specification in RFC 959.  In particular, each
  722.             line before the last must be formed by the reply code,
  723.             followed immediately by a hyphen, followed by a base 64
  724.             encoded fragment of the reply.
  725.  
  726.             For example, if the plaintext reply is
  727.  
  728.                123-First line
  729.                Second line
  730.                  234 A line beginning with numbers
  731.                123 The last line
  732.  
  733.             then the resulting protected reply could be any of the
  734.             following (the first example has a line break only to fit
  735.             within the margins):
  736.  
  737.   631 base64(protect("123-First line\r\nSecond line\r\n  234 A line
  738.  
  739.  
  740.  
  741. Horowitz & Lunt                                                [Page 12]
  742.  
  743. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  744.  
  745.  
  746.                   beginning with numbers\r\n123 The last line\r\n"))
  747.  
  748.   631-base64(protect("123-First line\r\n"))
  749.   631-base64(protect("Second line\r\n"))
  750.   631-base64(protect("  234 A line beginning with numbers\r\n"))
  751.   631 base64(protect("123 The last line"))
  752.  
  753.   631-base64(protect("123-First line\r\nSecond line\r\n  234 A line b"))
  754.   631 base64(protect("eginning with numbers\r\n123 The last line\r\n"))
  755.  
  756.  
  757. 6.  Data Channel Encapsulation
  758.  
  759.    When data transfers are protected between the client and server (in
  760.    either direction), certain transformations and encapsulations must be
  761.    performed so that the recipient can properly decode the transmitted
  762.    file.
  763.  
  764.    The sender must apply all protection services after transformations
  765.    associated with the representation type, file structure, and transfer
  766.    mode have been performed.  The data sent over the data channel is,
  767.    for the purposes of protection, to be treated as a byte stream.
  768.  
  769.    The sender must take the input byte stream, and break it up into
  770.    blocks such that each block, when encoded using a security mechanism
  771.    specific procedure, will be no larger than the buffer size negotiated
  772.    by the client with the PBSZ command.  Each block must be encoded,
  773.    then transmitted with the length of the encoded block prepended as a
  774.    four byte unsigned integer, most significant byte first.
  775.  
  776.    When the end of the file is reached, the sender must encode a block
  777.    of zero bytes, and send this final block to the recipient before
  778.    closing the data connection.
  779.  
  780.    The recipient will read the four byte length, read a block of data
  781.    that many bytes long, then decode and verify this block with a
  782.    security mechanism specific procedure.  This must be repeated until a
  783.    block encoding a buffer of zero bytes is received.  This indicates
  784.    the end of the encoded byte stream.
  785.  
  786.    Any transformations associated with the representation type, file
  787.    structure, and transfer mode are to be performed by the recipient on
  788.    the byte stream resulting from the above process.
  789.  
  790.    When using block transfer mode, the sender's (cleartext) buffer size
  791.    is independent of the block size.
  792.  
  793.    The server will reply 534 to a STOR, STOU, RETR, LIST, NLST, or APPE
  794.    command if the current protection level is not at the level dictated
  795.    by the server's security requirements for the particular file
  796.    transfer.
  797.  
  798.    If any data protection services fail at any time during data transfer
  799.    at the server end (including an attempt to send a buffer size greater
  800.  
  801.  
  802.  
  803. Horowitz & Lunt                                                [Page 13]
  804.  
  805. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  806.  
  807.  
  808.    than the negotiated maximum), the server will send a 535 reply to the
  809.    data transfer command (either STOR, STOU, RETR, LIST, NLST, or APPE).
  810.  
  811.  
  812. 7.  Potential policy considerations
  813.  
  814.    While there are no restrictions on client and server policy, there
  815.    are a few recommendations which an implementation should implement.
  816.  
  817.     - Once a security data exchange takes place, a server should require
  818.       all commands be protected (with integrity and/or confidentiality),
  819.       and it should protect all replies.  Replies should use the same
  820.       level of protection as the command which produced them.  This
  821.       includes replies which indicate failure of the MIC, CONF, and ENC
  822.       commands.  In particular, it is not meaningful to require that
  823.       AUTH and ADAT be protected; it is meaningful and useful to require
  824.       that PROT and PBSZ be protected.  In particular, the use of CCC is
  825.       not recommended, but is defined in the interest of
  826.       interoperability between implementations which might desire such
  827.       functionality.
  828.  
  829.     - A client should encrypt the PASS command whenever possible.  It is
  830.       reasonable for the server to refuse to accept a non-encrypted PASS
  831.       command if the server knows encryption is available.
  832.  
  833.     - Although no security commands are required to be implemented, it
  834.       is recommended that an implementation provide all commands which
  835.       can be implemented, given the mechanisms supported and the policy
  836.       considerations of the site (export controls, for instance).
  837.  
  838.  
  839. 8.  Declarative specifications
  840.  
  841.    These sections are modelled after sections 5.3 and 5.4 of RFC 959,
  842.    which describe the same information, except for the standard FTP
  843.    commands and replies.
  844.  
  845.  
  846.    8.1.  FTP Security commands and arguments
  847.  
  848.       AUTH <SP> <mechanism-name> <CRLF>
  849.       ADAT <SP> <base64data> <CRLF>
  850.       PROT <SP> <prot-code> <CRLF>
  851.       PBSZ <SP> <decimal-integer> <CRLF>
  852.       MIC <SP> <base64data> <CRLF>
  853.       CONF <SP> <base64data> <CRLF>
  854.       ENC <SP> <base64data> <CRLF>
  855.  
  856.       <mechanism-name> ::= <string>
  857.       <base64data> ::= <string>
  858.               ; must be formatted as described in section 9
  859.       <prot-code> ::= C | S | E | P
  860.       <decimal-integer> ::= any decimal integer from 1 to (2^32)-1
  861.  
  862.  
  863.  
  864.  
  865. Horowitz & Lunt                                                [Page 14]
  866.  
  867. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  868.  
  869.  
  870.    8.2.  Command-Reply sequences
  871.  
  872.       Security Association Setup
  873.          AUTH
  874.             234
  875.             334
  876.             502, 504, 534, 431
  877.             500, 501, 421
  878.          ADAT
  879.             235
  880.             335
  881.             503, 501, 535
  882.             500, 501, 421
  883.       Data protection negotiation commands
  884.          PBSZ
  885.             200
  886.             503
  887.             500, 501, 421, 530
  888.          PROT
  889.             200
  890.             504, 536, 503, 534, 431
  891.             500, 501, 421, 530
  892.       Command channel protection commands
  893.          MIC
  894.             535, 533
  895.             500, 501, 421
  896.          CONF
  897.             535, 533
  898.             500, 501, 421
  899.          ENC
  900.             535, 533
  901.             500, 501, 421
  902.       Security-Enhanced login commands (only new replies listed)
  903.          USER
  904.             232
  905.             336
  906.       Data channel commands (only new replies listed)
  907.          STOR
  908.             534, 535
  909.          STOU
  910.             534, 535
  911.          RETR
  912.             534, 535
  913.          LIST
  914.             534, 535
  915.          NLST
  916.             534, 535
  917.          APPE
  918.             534, 535
  919.  
  920.       In addition to these reply codes, any security command can return
  921.       500, 501, 502, 533, or 421.  Any ftp command can return a reply
  922.       code encapsulated in a 631, 632, or 633 reply once a security data
  923.       exchange has completed successfully.
  924.  
  925.  
  926.  
  927. Horowitz & Lunt                                                [Page 15]
  928.  
  929. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  930.  
  931.  
  932. 9.  State Diagrams
  933.  
  934.    This section includes a state diagram which demonstrates the flow of
  935.    authentication and authorization in a security enhanced FTP
  936.    implementation.  The rectangular blocks show states where the client
  937.    must issue a command, and the diamond blocks show states where the
  938.    server must issue a response.
  939.  
  940.           ,------------------,  USER
  941.        __\| Unauthenticated  |_________\
  942.       |  /| (new connection) |         /|
  943.       |   `------------------'          |
  944.       |            |                    |
  945.       |            | AUTH               |
  946.       |            V                    |
  947.       |           / \                   |
  948.       | 4yz,5yz  /   \   234            |
  949.       |<--------<     >------------->.  |
  950.       |          \   /               |  |
  951.       |           \_/                |  |
  952.       |            |                 |  |
  953.       |            | 334             |  |
  954.       |            V                 |  |
  955.       |  ,--------------------,      |  |
  956.       |  | Need Security Data |<--.  |  |
  957.       |  `--------------------'   |  |  |
  958.       |            |              |  |  |
  959.       |            | ADAT         |  |  |
  960.       |            V              |  |  |
  961.       |           / \             |  |  |
  962.       | 4yz,5yz  /   \   335      |  |  |
  963.       `<--------<     >-----------'  |  |
  964.                  \   /               |  |
  965.                   \_/                |  |
  966.                    |                 |  |
  967.                    | 235             |  |
  968.                    V                 |  |
  969.            ,---------------.         |  |
  970.       ,--->| Authenticated |<--------'  |  After the client and server
  971.       |    `---------------'            |  have completed authenti-
  972.       |            |                    |  cation, command must be
  973.       |            | USER               |  integrity-protected if
  974.       |            |                    |  integrity is available.  The
  975.       |            |<-------------------'  CCC command may be issued to
  976.       |            V                       relax this restriction.
  977.       |           / \
  978.       | 4yz,5yz  /   \   2yz
  979.       |<--------<     >------------->.
  980.       |          \   /               |
  981.       |           \_/                |
  982.       |            |                 |
  983.       |            | 3yz             |
  984.       |            V                 |
  985.  
  986.  
  987.  
  988.  
  989. Horowitz & Lunt                                                [Page 16]
  990.  
  991. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  992.  
  993.  
  994.       |    ,---------------.         |
  995.       |    | Need Password |         |
  996.       |    `---------------'         |
  997.       |            |                 |
  998.       |            | PASS            |
  999.       |            V                 |
  1000.       |           / \                |
  1001.       | 4yz,5yz  /   \   2yz         |
  1002.       |<--------<     >------------->|
  1003.       |          \   /               |
  1004.       |           \_/                |
  1005.       |            |                 |
  1006.       |            | 3yz             |
  1007.       |            V                 |
  1008.       |    ,--------------.          |
  1009.       |    | Need Account |          |
  1010.       |    `--------------'          |
  1011.       |            |                 |
  1012.       |            | ACCT            |
  1013.       |            V                 |
  1014.       |           / \                |
  1015.       | 4yz,5yz  /   \   2yz         |
  1016.       `<--------<     >------------->|
  1017.                  \   /               |
  1018.                   \_/                |
  1019.                    |                 |
  1020.                    | 3yz             |
  1021.                    V                 |
  1022.              ,-------------.         |
  1023.              | Authorized  |/________|
  1024.              | (Logged in) |\
  1025.              `-------------'
  1026.  
  1027.  
  1028. 10.  Base 64 Encoding
  1029.  
  1030.    Base 64 encoding is the same as the Printable Encoding described in
  1031.    Section 4.3.2.4 of [RFC-1421], except that line breaks must not be
  1032.    included. This encoding is defined as follows.
  1033.  
  1034.    Proceeding from left to right, the bit string resulting from the
  1035.    mechanism specific protection routine is encoded into characters
  1036.    which are universally representable at all sites, though not
  1037.    necessarily with the same bit patterns (e.g., although the character
  1038.    "E" is represented in an ASCII-based system as hexadecimal 45 and as
  1039.    hexadecimal C5 in an EBCDIC-based system, the local significance of
  1040.    the two representations is equivalent).
  1041.  
  1042.    A 64-character subset of International Alphabet IA5 is used, enabling
  1043.    6 bits to be represented per printable character.  (The proposed
  1044.    subset of characters is represented identically in IA5 and ASCII.)
  1045.    The character "=" signifies a special processing function used for
  1046.    padding within the printable encoding procedure.
  1047.  
  1048.  
  1049.  
  1050.  
  1051. Horowitz & Lunt                                                [Page 17]
  1052.  
  1053. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  1054.  
  1055.  
  1056.    The encoding process represents 24-bit groups of input bits as output
  1057.    strings of 4 encoded characters.  Proceeding from left to right
  1058.    across a 24-bit input group output from the security mechanism
  1059.    specific message protection procedure, each 6-bit group is used as an
  1060.    index into an array of 64 printable characters, namely "[A-Z][a-
  1061.    z][0-9]+/".  The character referenced by the index is placed in the
  1062.    output string.  These characters are selected so as to be universally
  1063.    representable, and the set excludes characters with particular
  1064.    significance to Telnet (e.g., "<CR>", "<LF>", IAC).
  1065.  
  1066.    Special processing is performed if fewer than 24 bits are available
  1067.    in an input group at the end of a message.  A full encoding quantum
  1068.    is always completed at the end of a message.  When fewer than 24
  1069.    input bits are available in an input group, zero bits are added (on
  1070.    the right) to form an integral number of 6-bit groups.  Output
  1071.    character positions which are not required to represent actual input
  1072.    data are set to the character "=".  Since all canonically encoded
  1073.    output is an integral number of octets, only the following cases can
  1074.    arise: (1) the final quantum of encoding input is an integral
  1075.    multiple of 24 bits; here, the final unit of encoded output will be
  1076.    an integral multiple of 4 characters with no "=" padding, (2) the
  1077.    final quantum of encoding input is exactly 8 bits; here, the final
  1078.    unit of encoded output will be two characters followed by two "="
  1079.    padding characters, or (3) the final quantum of encoding input is
  1080.    exactly 16 bits; here, the final unit of encoded output will be three
  1081.    characters followed by one "=" padding character.
  1082.  
  1083.    Implementors must keep in mind that the base 64 encodings in ADAT,
  1084.    MIC, CONF, and ENC commands, and in 63z replies may be arbitrarily
  1085.    long.  Thus, the entire line must be read before it can be processed.
  1086.    Several successive reads on the control channel may be necessary.  It
  1087.    is not appropriate to for a server to reject a command containing a
  1088.    base 64 encoding simply because it is too long (assuming that the
  1089.    decoding is otherwise well formed in the context in which it was
  1090.    sent).
  1091.  
  1092.    Case must not be ignored when reading commands and replies containing
  1093.    base 64 encodings.
  1094.  
  1095.  
  1096. 11.  Security Considerations
  1097.  
  1098.    This entire document deals with security considerations related to
  1099.    the File Transfer Protocol.
  1100.  
  1101.    Third party file transfers cannot be secured using these extensions,
  1102.    since a security context cannot be established between two servers
  1103.    using these facilities (no control connection exists between servers
  1104.    over which to pass ADAT tokens).  Further work in this area is
  1105.    deferred.
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113. Horowitz & Lunt                                                [Page 18]
  1114.  
  1115. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  1116.  
  1117.  
  1118. 12.  Acknowledgements
  1119.  
  1120.    I would like to thank the members of the CAT WG, as well as all
  1121.    participants in discussions on the "cat-ietf@mit.edu" mailing list,
  1122.    for their contributions to this document.  I would especially like to
  1123.    thank Sam Sjogren, John Linn, Ted Ts'o, Jordan Brown, Michael Kogut,
  1124.    Derrick Brashear, John Gardiner Myers, Denis Pinkas, and Kerri Balk
  1125.    for their contributions to this work.  Of course, without Steve Lunt,
  1126.    the author of the first six revisions of this document, it would not
  1127.    exist at all.
  1128.  
  1129.  
  1130. 13.  References
  1131.  
  1132.    [TELNET-SEC] Borman, D., "Telnet Authentication and Encryption
  1133.       Option", Internet Draft, Cray Research, Inc, April 1993.
  1134.  
  1135.    [RFC-1123] Braden, R., "Requirements for Internet Hosts --
  1136.       Application and Support", RFC 1123, October 1989.
  1137.  
  1138.    [RFC-1421] Linn, J., "Privacy Enhancement for Internet Electronic
  1139.       Mail: Part I: Message Encryption and Authentication Procedures",
  1140.       RFC 1421, February 1993.
  1141.  
  1142.  
  1143. 14.  Author's Address
  1144.  
  1145.    Marc Horowitz
  1146.    Cygnus Solutions
  1147.    955 Massachusetts Avenue
  1148.    Cambridge, MA 02139
  1149.  
  1150.    Phone: +1 617 354 7688
  1151.    Email: marc@cygnus.com
  1152.  
  1153. Appendix I: Specification under the GSSAPI
  1154.  
  1155.    In order to maximise the utility of new security mechanisms, it is
  1156.    desirable that new mechanisms be implemented as GSSAPI mechanisms
  1157.    rather than as FTP security mechanisms.  This will enable existing
  1158.    ftp implementations to support the new mechanisms more easily, since
  1159.    little or no code will need to be changed.  In addition, the
  1160.    mechanism will be usable by other protocols, such as IMAP, which are
  1161.    built on top of the GSSAPI, with no additional specification or
  1162.    implementation work needed by the mechanism designers.
  1163.  
  1164.    The security mechanism name (for the AUTH command) associated with
  1165.    all mechanisms employing the GSSAPI is GSSAPI.  If the server
  1166.    supports a security mechanism employing the GSSAPI, it must respond
  1167.    with a 334 reply code indicating that an ADAT command is expected
  1168.    next.
  1169.  
  1170.    The client must begin the authentication exchange by calling
  1171.    GSS_Init_Sec_Context, passing in 0 for input_context_handle
  1172.  
  1173.  
  1174.  
  1175. Horowitz & Lunt                                                [Page 19]
  1176.  
  1177. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  1178.  
  1179.  
  1180.    (initially), and a targ_name equal to output_name from
  1181.    GSS_Import_Name called with input_name_type of Host-Based Service and
  1182.    input_name_string of "ftp@hostname" where "hostname" is the fully
  1183.    qualified host name of the server with all letters in lower case.
  1184.    (Failing this, the client may try again using input_name_string of
  1185.    "host@hostname".) The output_token must then be base 64 encoded and
  1186.    sent to the server as the argument to an ADAT command.  If
  1187.    GSS_Init_Sec_Context returns GSS_S_CONTINUE_NEEDED, then the client
  1188.    must expect a token to be returned in the reply to the ADAT command.
  1189.    This token musr subsequently be passed to another call to
  1190.    GSS_Init_Sec_Context.  In this case, if GSS_Init_Sec_Context returns
  1191.    no output_token, then the reply code from the server for the previous
  1192.    ADAT command must have been 235.  If GSS_Init_Sec_Context returns
  1193.    GSS_S_COMPLETE, then no further tokens are expected from the server,
  1194.    and the client must consider the server authenticated.
  1195.  
  1196.    The server must base 64 decode the argument to the ADAT command and
  1197.    pass the resultant token to GSS_Accept_Sec_Context as input_token,
  1198.    setting acceptor_cred_handle to NULL (for "use default credentials"),
  1199.    and 0 for input_context_handle (initially).  If an output_token is
  1200.    returned, it must be base 64 encoded and returned to the client by
  1201.    including "ADAT=base64string" in the text of the reply.  If
  1202.    GSS_Accept_Sec_Context returns GSS_S_COMPLETE, the reply code must be
  1203.    235, and the server must consider the client authenticated.  If
  1204.    GSS_Accept_Sec_Context returns GSS_S_CONTINUE_NEEDED, the reply code
  1205.    must be 335.  Otherwise, the reply code should be 535, and the text
  1206.    of the reply should contain a descriptive error message.
  1207.  
  1208.    The chan_bindings input to GSS_Init_Sec_Context and
  1209.    GSS_Accept_Sec_Context should use the client address and server
  1210.    internet address as the initiator and acceptor addresses,
  1211.    respectively.  The address type for both should be GSS_C_AF_INET. No
  1212.    application data should be specified.
  1213.  
  1214.    Since GSSAPI supports anonymous peers to security contexts, it is
  1215.    possible that the client's authentication of the server or vice versa
  1216.    does not actually establish an identity.
  1217.  
  1218.    The procedure associated with MIC commands, 631 replies, and Safe
  1219.    file transfers is:
  1220.  
  1221.       GSS_Wrap for the sender, with conf_flag == FALSE
  1222.       GSS_Unwrap for the receiver
  1223.  
  1224.    The procedure associated with ENC commands, 632 replies, and Private
  1225.    file transfers is:
  1226.  
  1227.       GSS_Wrap for the sender, with conf_flag == TRUE
  1228.       GSS_Unwrap for the receiver
  1229.  
  1230.    CONF commands and 633 replies are not supported.
  1231.  
  1232.    Both the client and server should inspect the value of conf_avail to
  1233.    determine whether the peer supports confidentiality services.
  1234.  
  1235.  
  1236.  
  1237. Horowitz & Lunt                                                [Page 20]
  1238.  
  1239. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  1240.  
  1241.  
  1242.    When the security state is reset (when AUTH is received a second
  1243.    time, or when REIN is received), this should be done by calling the
  1244.    GSS_Delete_sec_context function.
  1245.  
  1246. Appendix II:  Specification under Kerberos version 4
  1247.  
  1248.    The security mechanism name (for the AUTH command) associated with
  1249.    Kerberos Version 4 is KERBEROS_V4.  If the server supports
  1250.    KERBEROS_V4, it must respond with a 334 reply code indicating that an
  1251.    ADAT command is expected next.
  1252.  
  1253.    The client must retrieve a ticket for the Kerberos principal
  1254.    "ftp.hostname@realm" by calling krb_mk_req(3) with a principal name
  1255.    of "ftp", an instance equal to the first part of the canonical host
  1256.    name of the server with all letters in lower case (as returned by
  1257.    krb_get_phost(3)), the server's realm name (as returned by
  1258.    krb_realmofhost(3)), and an arbitrary checksum.  The ticket must then
  1259.    be base 64 encoded and sent as the argument to an ADAT command.
  1260.  
  1261.    If the "ftp" principal name is not a registered principal in the
  1262.    Kerberos database, then the client may fall back on the "rcmd"
  1263.    principal name (same instance and realm).  However, servers must
  1264.    accept only one or the other of these principal names, and must not
  1265.    be willing to accept either.  Generally, if the server has a key for
  1266.    the "ftp" principal in its srvtab, then that principal only must be
  1267.    used, otherwise the "rcmd" principal only must be used.
  1268.  
  1269.    The server must base 64 decode the argument to the ADAT command and
  1270.    pass the result to krb_rd_req(3).  The server must add one to the
  1271.    checksum from the authenticator, convert the result to network byte
  1272.    order (most significant byte first), and sign it using
  1273.    krb_mk_safe(3), and base 64 encode the result.  Upon success, the
  1274.    server must reply to the client with a 235 code and include
  1275.    "ADAT=base64string" in the text of the reply.  Upon failure, the
  1276.    server should reply 535.
  1277.  
  1278.    Upon receipt of the 235 reply from the server, the client must parse
  1279.    the text of the reply for the base 64 encoded data, decode it,
  1280.    convert it from network byte order, and pass the result to
  1281.    krb_rd_safe(3).  The client must consider the server authenticated if
  1282.    the resultant checksum is equal to one plus the value previously
  1283.    sent.
  1284.  
  1285.    The procedure associated with MIC commands, 631 replies, and Safe
  1286.    file transfers is:
  1287.  
  1288.       krb_mk_safe(3) for the sender
  1289.       krb_rd_safe(3) for the receiver
  1290.  
  1291.    The procedure associated with ENC commands, 632 replies, and Private
  1292.    file transfers is:
  1293.  
  1294.       krb_mk_priv(3) for the sender
  1295.       krb_rd_priv(3) for the receiver
  1296.  
  1297.  
  1298.  
  1299. Horowitz & Lunt                                                [Page 21]
  1300.  
  1301. draft-ietf-cat-ftpsec-09.tFxTtP Security Extensions          November, 1996
  1302.  
  1303.  
  1304.    CONF commands and 633 replies are not supported.
  1305.  
  1306.    Note that this specification for KERBEROS_V4 contains no provision
  1307.    for negotiating alternate means for integrity and confidentiality
  1308.    routines.  Note also that the ADAT exchange does not convey whether
  1309.    the peer supports confidentiality services.
  1310.  
  1311.    In order to stay within the allowed PBSZ, implementors must take note
  1312.    that a cleartext buffer will grow by 31 bytes when processed by
  1313.    krb_mk_safe(3) and will grow by 26 bytes when processed by
  1314.    krb_mk_priv(3).
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.  
  1327.  
  1328.  
  1329.  
  1330.  
  1331.  
  1332.  
  1333.  
  1334.  
  1335.  
  1336.  
  1337.  
  1338.  
  1339.  
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361. Horowitz & Lunt                                                [Page 22]
  1362.  
  1363.