chiark / gitweb /
changelog: finalise 1.3.5
[chiark-tcl.git] / crypto / crypto.c
index e8d7f1a64dfff433a848b4c1f555e0f20a9d3c68..6efea24f325ce5b7079087e5b64082b33c32ce39 100644 (file)
@@ -1,6 +1,22 @@
 /*
+ * crypto - Tcl bindings for parts of the `nettle' crypto library
+ * Copyright 2006-2012 Ian Jackson
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
+
 #include "chiark_tcl_crypto.h"
 
 const PadOp cht_padop_entries[]= {
@@ -129,15 +145,6 @@ int cht_do_padmethodinfo_pkcs5(ClientData cd, Tcl_Interp *ip, int *ok) {
   return TCL_OK;
 }
 
-int cht_do_hbcrypto_hash(ClientData cd, Tcl_Interp *ip, const HashAlgInfo *alg,
-                  HBytes_Value message, HBytes_Value *result) {
-  Byte *dest;
-
-  dest= cht_hb_arrayspace(result,alg->hashsize);
-  alg->oneshot(dest, cht_hb_data(&message), cht_hb_len(&message));
-  return TCL_OK;
-}
-
 #define OBJ_CIPHKEY(o) ((CiphKeyValue*)(o)->internalRep.otherValuePtr)
 
 typedef struct {
@@ -177,7 +184,7 @@ static void key_t_dup(Tcl_Obj *src_obj, Tcl_Obj *dup_obj) {
 }
 
 static void key_t_ustr(Tcl_Obj *o) {
-  obj_updatestr_array(o, OBJ_CIPHKEY(o)->value, OBJ_CIPHKEY(o)->valuelen);
+  cht_obj_updatestr_array(o, OBJ_CIPHKEY(o)->value, OBJ_CIPHKEY(o)->valuelen);
 }
 
 static int key_t_sfa(Tcl_Interp *ip, Tcl_Obj *o) {
@@ -245,6 +252,14 @@ static int blockcipher_prep(Tcl_Interp *ip, Tcl_Obj *key_obj,
   int rc;
   CiphKeyValue *key;
 
+  /* placate gcc, see Debian #968734 */
+  *key_r= 0;
+  *sched_r= 0;
+  *iv_r= 0;
+  *iv_lenbytes_r= 0;
+  *buffers_r= 0;
+  *nblocks_r= 0;
+
   if (data_len % alg->blocksize)
     return cht_staticerr(ip, "block cipher input not whole number of blocks",
                     "HBYTES BLOCKCIPHER LENGTH");