BSD 4_4_Lite2 release
[unix-history] / usr / src / lib / libtelnet / encrypt.c
index c2b9015..432df0c 100644 (file)
@@ -1,12 +1,38 @@
 /*-
 /*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1991, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)encrypt.c  5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)encrypt.c  8.2 (Berkeley) 5/30/95";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -29,7 +55,7 @@ static char sccsid[] = "@(#)encrypt.c 5.3 (Berkeley) %G%";
  * or implied warranty.
  */
 
  * or implied warranty.
  */
 
-#if    defined(ENCRYPTION)
+#ifdef ENCRYPTION
 
 #define        ENCRYPT_NAMES
 #include <arpa/telnet.h>
 
 #define        ENCRYPT_NAMES
 #include <arpa/telnet.h>
@@ -78,9 +104,9 @@ static long remote_supports_encrypt = 0;
 static long remote_supports_decrypt = 0;
 
 static Encryptions encryptions[] = {
 static long remote_supports_decrypt = 0;
 
 static Encryptions encryptions[] = {
-#if    defined(DES_ENCRYPTION)
+#ifdef DES_ENCRYPTION
     { "DES_CFB64",     ENCTYPE_DES_CFB64,
     { "DES_CFB64",     ENCTYPE_DES_CFB64,
-                       cfb64_encrypt,  
+                       cfb64_encrypt,
                        cfb64_decrypt,
                        cfb64_init,
                        cfb64_start,
                        cfb64_decrypt,
                        cfb64_init,
                        cfb64_start,
@@ -90,7 +116,7 @@ static Encryptions encryptions[] = {
                        cfb64_keyid,
                        cfb64_printsub },
     { "DES_OFB64",     ENCTYPE_DES_OFB64,
                        cfb64_keyid,
                        cfb64_printsub },
     { "DES_OFB64",     ENCTYPE_DES_OFB64,
-                       ofb64_encrypt,  
+                       ofb64_encrypt,
                        ofb64_decrypt,
                        ofb64_init,
                        ofb64_start,
                        ofb64_decrypt,
                        ofb64_init,
                        ofb64_start,
@@ -99,7 +125,7 @@ static Encryptions encryptions[] = {
                        ofb64_session,
                        ofb64_keyid,
                        ofb64_printsub },
                        ofb64_session,
                        ofb64_keyid,
                        ofb64_printsub },
-#endif
+#endif /* DES_ENCRYPTION */
     { 0, },
 };
 
     { 0, },
 };
 
@@ -682,7 +708,7 @@ encrypt_request_end()
  * Called when ENCRYPT REQUEST-START is received.  If we receive
  * this before a type is picked, then that indicates that the
  * other side wants us to start encrypting data as soon as we
  * Called when ENCRYPT REQUEST-START is received.  If we receive
  * this before a type is picked, then that indicates that the
  * other side wants us to start encrypting data as soon as we
- * can. 
+ * can.
  */
        void
 encrypt_request_start(data, cnt)
  */
        void
 encrypt_request_start(data, cnt)
@@ -737,12 +763,13 @@ encrypt_keyid(kp, keyid, len)
                if (ep->keyid)
                        (void)(*ep->keyid)(dir, kp->keyid, &kp->keylen);
 
                if (ep->keyid)
                        (void)(*ep->keyid)(dir, kp->keyid, &kp->keylen);
 
-       } else if ((len != kp->keylen) || (bcmp(keyid, kp->keyid, len) != 0)) {
+       } else if ((len != kp->keylen) ||
+                  (memcmp(keyid, kp->keyid, len) != 0)) {
                /*
                 * Length or contents are different
                 */
                kp->keylen = len;
                /*
                 * Length or contents are different
                 */
                kp->keylen = len;
-               bcopy(keyid, kp->keyid, len);
+               memmove(kp->keyid, keyid, len);
                if (ep->keyid)
                        (void)(*ep->keyid)(dir, kp->keyid, &kp->keylen);
        } else {
                if (ep->keyid)
                        (void)(*ep->keyid)(dir, kp->keyid, &kp->keylen);
        } else {
@@ -769,7 +796,7 @@ encrypt_send_keyid(dir, keyid, keylen, saveit)
                        ? ENCRYPT_ENC_KEYID : ENCRYPT_DEC_KEYID;
        if (saveit) {
                struct key_info *kp = &ki[(dir == DIR_ENCRYPT) ? 0 : 1];
                        ? ENCRYPT_ENC_KEYID : ENCRYPT_DEC_KEYID;
        if (saveit) {
                struct key_info *kp = &ki[(dir == DIR_ENCRYPT) ? 0 : 1];
-               bcopy(keyid, kp->keyid, keylen);
+               memmove(kp->keyid, keyid, keylen);
                kp->keylen = keylen;
        }
 
                kp->keylen = keylen;
        }
 
@@ -825,7 +852,7 @@ encrypt_start_output(type)
                i = (*ep->start)(DIR_ENCRYPT, Server);
                if (encrypt_debug_mode) {
                        printf(">>>%s: Encrypt start: %s (%d) %s\r\n",
                i = (*ep->start)(DIR_ENCRYPT, Server);
                if (encrypt_debug_mode) {
                        printf(">>>%s: Encrypt start: %s (%d) %s\r\n",
-                               Name, 
+                               Name,
                                (i < 0) ? "failed" :
                                        "initial negotiation in progress",
                                i, ENCTYPE_NAME(type));
                                (i < 0) ? "failed" :
                                        "initial negotiation in progress",
                                i, ENCTYPE_NAME(type));
@@ -970,4 +997,4 @@ encrypt_printsub(data, cnt, buf, buflen)
        else
                encrypt_gen_printsub(data, cnt, buf, buflen);
 }
        else
                encrypt_gen_printsub(data, cnt, buf, buflen);
 }
-#endif
+#endif /* ENCRYPTION */