Index: yc_sha.c
===================================================================
--- /YC3121_SDK/fw/crypt/yc_sha.c	(revision 570)
+++ /YC3121_SDK/fw/crypt/yc_sha.c	(working copy)
@@ -155,21 +155,32 @@
         j = i;
     }
 
-	SHA_BDATA(j) = input;
-	if((istep & 3) == 3 && maxlen == 64)
-	{
-		SHA_BDATA(j + 1) = 0;
-		SHA_BDATA(j + 2) = 0;
-		SHA_BDATA(j + 3) = 0;
-		SHA_BDATA(j + 4) = 0;
-		j+=4;
-	}
-
-    if(istep%maxlen==maxlen-1)
-    {
-        SHA_CTRL = mode | 0x20 | (istep > (maxlen-1) ? 0x10 : 0);
-		while(SHA_CTRL & 0x80);
-    }
+		if(isend!=2)
+		{
+			SHA_BDATA(j) = input;
+			if((istep & 3) == 3 && maxlen == 64)
+			{
+				SHA_BDATA(j + 1) = 0;
+				SHA_BDATA(j + 2) = 0;
+				SHA_BDATA(j + 3) = 0;
+				SHA_BDATA(j + 4) = 0;
+				j+=4;
+			}
+
+			if(istep%maxlen==maxlen-1)
+			{
+				SHA_CTRL = mode | 0x20 | (istep > (maxlen-1) ? 0x10 : 0);
+				while(SHA_CTRL & 0x80);
+			}
+		}
+		else
+		{
+			if((istep & 3) == 3 && maxlen == 64)
+			{
+				j+=4;
+			}
+		}
+	
     bytes = istep + 1;
 
     if(isend)
@@ -242,8 +253,15 @@
 uint32_t sha_last(SHA_ModeTypeDef mode,uint8_t *output,uint8_t *input,uint32_t ibytes)
 {
   uint32_t i = 0;
-  for(i = 0;i < ibytes-1;i++)
-		SHA_BYTE(mode, NULL,input[i],sha_totallen++,0);
-	SHA_BYTE(mode, output,input[i],sha_totallen++,1);
-	return RET_SHA_SUCCESS;
+  if(ibytes==0)
+  {
+	  SHA_BYTE(mode, output,input[i],--sha_totallen,2);
+  }
+  else
+  {
+	  for(i = 0;i < ibytes-1;i++)
+			SHA_BYTE(mode, NULL,input[i],sha_totallen++,0);
+	  SHA_BYTE(mode, output,input[i],sha_totallen++,1);
+  }
+  return RET_SHA_SUCCESS;
 }
\ No newline at end of file
