Kaynağa Gözat

* Correct encoding

Michael VAN CANNEYT 2 yıl önce
ebeveyn
işleme
78353ad16e
1 değiştirilmiş dosya ile 10 ekleme ve 2 silme
  1. 10 2
      packages/fcl-web/src/jwt/fpjwaes256.pp

+ 10 - 2
packages/fcl-web/src/jwt/fpjwaes256.pp

@@ -60,7 +60,7 @@ end;
 Class function TJWTSignerES256.Verify(const aJWT: String; aPrivateKey: TECCPrivateKey): Boolean;
 
 Var
-  J,C,S : AnsiString;
+  J,C,S : String;
   aSignature : TEccSignature;
   B : TBytes;
 
@@ -68,7 +68,11 @@ begin
   Result:=GetParts(aJWT,J,C,S);
   if Not Result then
     exit;
+{$IF SIZEOF(CHAR)=2}    
+  B:=TEncoding.UTF8.GetBytes(J+'.'+C);
+{$ELSE}  
   B:=TEncoding.UTF8.GetAnsiBytes(J+'.'+C);
+{$ENDIF}  
   BytesToVar(Base64url.Decode(S),aSignature,Sizeof(aSignature));
   Result:=TECDSA.verifySHA256(B,aPrivateKey,aSignature);
 end;
@@ -76,7 +80,7 @@ end;
 class function TJWTSignerES256.Verify(const aJWT: String; aPublicKey: TECCPublicKey): Boolean;
 
 Var
-  J,C,S : AnsiString;
+  J,C,S : String;
   aSignature : TEccSignature;
   B : TBytes;
 
@@ -84,7 +88,11 @@ begin
   Result:=GetParts(aJWT,J,C,S);
   if Not Result then
     exit;
+{$IF SIZEOF(CHAR)=2}    
+  B:=TEncoding.UTF8.GetBytes(J+'.'+C);
+{$ELSE}     
   B:=TEncoding.UTF8.GetAnsiBytes(J+'.'+C);
+{$ENDIF}  
   Base64url.Decode(S,@aSignature);
   Result:=TECDSA.verifySHA256(B,aPublicKey,aSignature);
 end;