forked from sergeych/crypto2
		
	seal now allows up to 45s in future to tolerate some time difference
This commit is contained in:
		
							parent
							
								
									242cc7d0f5
								
							
						
					
					
						commit
						7fa3ab1ca8
					
				@ -9,7 +9,7 @@ plugins {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
group = "net.sergeych"
 | 
			
		||||
version = "0.7.1-SNAPSHOT"
 | 
			
		||||
version = "0.7.2-SNAPSHOT"
 | 
			
		||||
 | 
			
		||||
repositories {
 | 
			
		||||
    mavenCentral()
 | 
			
		||||
 | 
			
		||||
@ -6,6 +6,7 @@ import net.sergeych.bipack.BipackEncoder
 | 
			
		||||
import net.sergeych.bipack.decodeFromBipack
 | 
			
		||||
import net.sergeych.crypto2.Seal.Companion.create
 | 
			
		||||
import net.sergeych.utools.now
 | 
			
		||||
import kotlin.time.Duration.Companion.seconds
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Extended public-key signature.
 | 
			
		||||
@ -67,7 +68,7 @@ class Seal(
 | 
			
		||||
     */
 | 
			
		||||
    fun verify(message: UByteArray) {
 | 
			
		||||
        val n = now()
 | 
			
		||||
        if (createdAt > n) throw IllegalSignatureException("signature's timestamp in the future")
 | 
			
		||||
        if (createdAt - 45.seconds > n) throw IllegalSignatureException("signature's timestamp in the future: $createdAt / $n")
 | 
			
		||||
        expiresAt?.let {
 | 
			
		||||
            if (n >= it) throw ExpiredSignatureException("signature expired at $it")
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user