How to verify authentication tag during chunked AES-GSM-128 decryption (2024)

  • Home
  • Forums
  • All Topics
  • Technology
  • Thread starterLesha Pipiev
  • Start dateYesterday at 12:17 PM
  • Tags
    None

L

Lesha Pipiev

  • Yesterday at 12:17 PM
  • #1

Due to there are large encrypted files we are dealing with, we can't afford to keep entire file in memory during a decryption process.
I've implemented the algorithm of chunked decryption of AES GSM encrypted file.

Code:

const ( tagSizeInBytes = 16 BufferSizeInBytes = 5 * 1024 * 1024)func DecryptFile(encryptedFile, decryptedFile *os.File, encryptedFileSize int64, dataKey, iv []byte) error { sizeOfEncryptedFileWithoutTag := encryptedFileSize - int64(tagSizeInBytes) c, err := aes.NewCipher(dataKey) if err != nil { return err } var encryptedChunk = make([]byte, BufferSizeInBytes) var lastIteration = false var offset = 0 for { nBytes, err := encryptedFile.Read(encryptedChunk) if err != nil { if err != io.EOF { fmt.Println(err) } break } if int64(offset+BufferSizeInBytes) >= sizeOfEncryptedFileWithoutTag { var endIndex = sizeOfEncryptedFileWithoutTag - int64(offset) if endIndex < 0 { endIndex = int64(nBytes) } encryptedChunk = encryptedChunk[0:endIndex] lastIteration = true } // iv is of 12 bytes size // counter has to be 16 bytes size extra := make([]byte, 4) counter := append(iv, extra[:]...) // in order to "jump" to specific offset in encrypted message, // we need to increment counter // init counter inc(counter) for i := 0; i < offset/aes.BlockSize+1; i++ { inc(counter) } var endIndex = offset + BufferSizeInBytes if endIndex > len(encryptedChunk) { endIndex = len(encryptedChunk) } encryptedBlock := encryptedChunk[0:endIndex] ctr := cipher.NewCTR(c, counter) plain := make([]byte, len(encryptedBlock)) ctr.XORKeyStream(plain, encryptedBlock) if _, err = decryptedFile.Write(plain); err != nil { fmt.Println(err) os.Exit(1) } offset += BufferSizeInBytes if lastIteration { break } } return nil}

The method works fine, but there is no tag authentication check.
Is it possible to implement tag verification for chunked AES-GCM decryption?

Login To add answer/comment

Unreplied Threads

Understanding the components of backlight circuit of digital watch

  • Naveen
  • Physics
  • Replies: 0

I am not a hardware engineer. I studied basic electronics 15 years back in school days, so you can consider me a noob. I have a digital watch in which all the features (time, alarm, chime, etc) work fine, except the backlight. This watch is just 2 years old. I opened the watch and the internals were very clean, no sign of rust, etc. Now, the button that's responsible for glowing backlight should also have proper contact because when there is an alarm, pressing the light button stops it, so I assume the button is fine. I don't think the EL panel has gone bad because the EL was rarely used in last 2 years. So I first want to start confirming that the components in EL circuit are fine.

Just by looking at the watch, I definitely can't guess what makes the EL circuit but I am starting with the button for backlight and following the trails. I can identify few SMD components like diodes, quartz and resistors, but there are some which I am not able to.

Below are the front and back screenshots How to verify authentication tag during chunked AES-GSM-128 decryption (1) How to verify authentication tag during chunked AES-GSM-128 decryption (2) Below are some closeups where I suspect the EL circuit component lie : How to verify authentication tag during chunked AES-GSM-128 decryption (3) How to verify authentication tag during chunked AES-GSM-128 decryption (4)

Questions :

  1. What is this component that looks like a red tube? That's also black from one corner. I suspect it. Can this be tested by a multimeter?
  2. What's the best way to verify the EL circuit is fine? Is my idea of verifying each component with multimeter fine? (I am not sure if all the components can be verified with a multimeter).

I do have a basic multimeter with me.

Does the air gap between the metal target and coil in an inductive position sensor change the position value?

  • umh
  • Physics
  • Replies: 0

I am trying to design an inductive position sensor with the inductive sensor IC ZMID5201.

How to verify authentication tag during chunked AES-GSM-128 decryption (5)

I am trying to optimize the air gap betweeen sensor coil and metal target. The datasheet mentions that the output signal remains stable even if the gap between sensor coils and target is varied.

Can anyone explain the theory behind this constant output signal?

How to verify authentication tag during chunked AES-GSM-128 decryption (6)

python. flet. Как в режиме WEB получить содержимое загруженного файла

  • Сергей Попков
  • Technology
  • Replies: 0

У меня была простая цель, приложение в режиме WEB по кнопке открывает выбор файла, я выбираю себе файл конфига например и содержимое файла появляется в TextField.

Вот скрипт заготовка:

Code:

import flet as ftdef main(page: ft.Page): page.padding = ft.Padding(top=60, bottom=60, left=250, right=250) def on_dialog_result(e: ft.FilePickerResultEvent): content = str(e.data) + "\n" + str(e.files) text_field.value = text_field.value + "\n" + content text_field.update() file_picker = ft.FilePicker(on_result=on_dialog_result) page.overlay.append(file_picker) page.update() text_field = ft.TextField(multiline=True, min_lines=10, max_lines=15, border_color=ft.colors.WHITE) page.add( text_field, ft.Row([ft.IconButton(icon=ft.icons.FILE_DOWNLOAD, bgcolor=ft.colors.INDIGO, on_click=lambda _: file_picker.pick_files())], alignment=ft.MainAxisAlignment.END ) )ft.app(target=main, view=ft.WEB_BROWSER)

Для меня это оказалось непосильной задачей. Помогите разобраться?

How to Ask a Top Professor to Co-Author a Paper with Me?

  • The_old_man
  • Education
  • Replies: 0

I am currently working on a research project that I believe has significant potential. I have identified a top professor in my field whose expertise aligns perfectly with my research topic. I would like to ask this professor to co-author a paper with me, but I am unsure how to approach this request professionally and effectively.

Are there any tips on things to do and not to do? Anything I should be considering?

I plan to send an email with my abstract, see if the professor is interested. Then I will discuss roles with him and wait for him to finish revising my paper.

Is it appropriate to award points for this answer? (experimental physics)

  • Allure
  • Education
  • Replies: 0

The experiment in question asks the student to take several measurements for the period with different pendulum lengths.* Then it asks the student to pick a length, with justification, before proceeding to more complicated experiments.

The intended answer as given by the grading scheme is:

The student should pick the longest length. This is because the longest length has the lowest percentage error.

The answer that a student wrote is:

I pick the shortest length. This is because I only have 15 minutes left to do the rest of the experiment, so I cannot wait a long time between measurements.**

The student's answer is not wrong, in fact it is a very good reason, but it's completely different from the answer in the grading scheme. Is it appropriate to award points? If it is appropriate, is partial or full credit correct?

Related: Is it ethical to award points for hilariously bad answers? This answer is funny in its own way, but it's not hilariously bad.

*The length of a pendulum is related to its period by T = 2pi sqrt(L/g), where L is the length of the pendulum and T is the period. In other words, a longer pendulum takes longer to oscillate.

**The description of the experiment I gave is simplified. In the actual experiment, it takes up to one minute between measurements while using the longer length. With shorter length, it takes ~10 seconds.

Citation for a processor instruction set?

  • drjrm3
  • Education
  • Replies: 0

I am writing a paper where I am talking about the SSE and AVX instruction sets. For a hardware feature like an instruction set, I am wondering how to figure out what is an appropriate citation to use, or if it should be cited at all?

Flower bend difficulty

  • Dennis Klerkx
  • Technology
  • Replies: 0

I have a simple flower on a flat plane. I want to bend the flower along the z axis, so it folds to the inside but limited to a certain point (like the image). The problem is, I want this limit to have a smoother falloff. I got the bend correct, the bottom part should bend more than the “leave” part (see nodes) but the border needs to be not that abrupt. If that makes sense. Maybe this is a simple solution but I can’t get it to work. So any info could help!

How to verify authentication tag during chunked AES-GSM-128 decryption (7)

How to verify authentication tag during chunked AES-GSM-128 decryption (2024)
Top Articles
Latest Posts
Article information

Author: Rev. Porsche Oberbrunner

Last Updated:

Views: 5930

Rating: 4.2 / 5 (73 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Rev. Porsche Oberbrunner

Birthday: 1994-06-25

Address: Suite 153 582 Lubowitz Walks, Port Alfredoborough, IN 72879-2838

Phone: +128413562823324

Job: IT Strategist

Hobby: Video gaming, Basketball, Web surfing, Book restoration, Jogging, Shooting, Fishing

Introduction: My name is Rev. Porsche Oberbrunner, I am a zany, graceful, talented, witty, determined, shiny, enchanting person who loves writing and wants to share my knowledge and understanding with you.