mirror of
				https://github.com/gnh1201/welsonjs.git
				synced 2025-10-31 04:51:17 +00:00 
			
		
		
		
	Changed file header comments in cryptography-related modules from '.cs' to '.vb' to accurately reflect the file types. This improves clarity and consistency in source file documentation.
		
			
				
	
	
		
			56 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			VB.net
		
	
	
	
	
	
			
		
		
	
	
			56 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			VB.net
		
	
	
	
	
	
| ' HightAlgorithm.vb (WelsonJS.Cryptography)
 | |
| ' SPDX-License-Identifier: MIT
 | |
| ' SPDX-FileCopyrightText: 2025 Namhyeon Go <gnh1201@catswords.re.kr>, Catswords OSS And WelsonJS Contributors
 | |
| ' https://github.com/gnh1201/welsonjs
 | |
| ' 
 | |
| Imports System.Security.Cryptography
 | |
| 
 | |
| Public Class HightAlgorithm
 | |
|     Inherits SymmetricAlgorithm
 | |
| 
 | |
|     Public Sub New()
 | |
|         LegalBlockSizesValue = New KeySizes() {New KeySizes(64, 64, 0)}
 | |
|         LegalKeySizesValue = New KeySizes() {New KeySizes(128, 128, 0)}
 | |
| 
 | |
|         Me.BlockSize = 64
 | |
|         Me.KeySize = 128
 | |
|         Me.FeedbackSize = 64
 | |
| 
 | |
|         Me.Mode = CipherMode.ECB
 | |
|         Me.Padding = PaddingMode.PKCS7
 | |
| 
 | |
|         Me.Key = New Byte(15) {}
 | |
|         Me.IV = New Byte(7) {}
 | |
|     End Sub
 | |
| 
 | |
|     Public Overrides Sub GenerateKey()
 | |
|         Using rng As New RNGCryptoServiceProvider()
 | |
|             rng.GetBytes(Me.Key)
 | |
|         End Using
 | |
|     End Sub
 | |
| 
 | |
|     Public Overrides Sub GenerateIV()
 | |
|         Using rng As New RNGCryptoServiceProvider()
 | |
|             rng.GetBytes(Me.IV)
 | |
|         End Using
 | |
|     End Sub
 | |
| 
 | |
|     Public Overrides Function CreateEncryptor(rgbKey As Byte(), rgbIV As Byte()) As ICryptoTransform
 | |
|         Return CreateTransform(rgbKey, rgbIV, True)
 | |
|     End Function
 | |
| 
 | |
|     Public Overrides Function CreateDecryptor(rgbKey As Byte(), rgbIV As Byte()) As ICryptoTransform
 | |
|         Return CreateTransform(rgbKey, rgbIV, False)
 | |
|     End Function
 | |
| 
 | |
|     Private Function CreateTransform(key As Byte(), iv As Byte(), encrypt As Boolean) As ICryptoTransform
 | |
|         Select Case Me.Mode
 | |
|             Case CipherMode.ECB
 | |
|                 Return New HightEcbTransform(key, encrypt, Me.Padding)
 | |
|             Case Else
 | |
|                 Throw New NotSupportedException("This mode not supported yet")
 | |
|         End Select
 | |
|     End Function
 | |
| 
 | |
|     ' TODO: CCM, GCM, CMAC
 | |
| End Class |